Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gsm_call_dial() function locks the program #34

Closed
ogulcan90 opened this issue Aug 20, 2021 · 4 comments
Closed

gsm_call_dial() function locks the program #34

ogulcan90 opened this issue Aug 20, 2021 · 4 comments

Comments

@ogulcan90
Copy link

ogulcan90 commented Aug 20, 2021

Hi,

I tried the library and I can send sms properly, but when I try to make phone call, the program stucks in a way that all tasks stop working.

Here is my FreeRTOS configuration:
image

Here is my gsmTask:
image

Here is my GSMRun Task:
image

It sends the AT command, my phone rings, so when I debug, I see that the PC comes here (line 39 of call.c, inside gsm_call_dial() function):
image

Then it goes to atc_command() function and spends some time in this loop (located between line 195 & line 198 of atc.c):
image

Then I press resume to see where it stucks, and I see that it stucks in line 278 of heap_4.c:
configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 );
image

which is in vPortFree function.

This means the FreeRTOS somehow cannot deallocate the memory that it allocated before.

Does anyone has any idea on the solution of this problem?

Thank you.
Cheers,
Ogulcan

@nimaltd
Copy link
Owner

nimaltd commented Aug 22, 2021

Hello. Please increase FREERTOS heap size and try again.

@ogulcan90
Copy link
Author

ogulcan90 commented Aug 24, 2021

Here is my FreeRTOS heap size:
image

I also increased tasks' stack sizes a little more:
image

But still I have the same problem...

Do you have any other suggestions?

Thanks.
Ogulcan

@d-serj
Copy link
Contributor

d-serj commented Aug 25, 2021

Hi @ogulcan90
According to the assertion you are trying to free the memory that was not allocated before.

Why it is happening is very interesting issue to dive in 🙂

First of all it could be because you are trying to free the memory twice. If you are trying to free the memory twice most likely that you are using this already freed memory in other places that would lead to heap memory corruption. Thats why it is very good programming practice to set all the pointers to NULL after they were freed.

Also you can try step by step debugging and make yourself sure that memory was allocated well and pointer holds actual value to this memory. If memory was allocated well save the value where the pointer is pointing to. Then at vPortFree call compare saved value with actual value that is passing as a parameter to vPortFree. If they are different most likely you faced with stack memory corruption and the pointer value was overwritten somewhere in the stack.

@ogulcan90
Copy link
Author

Hi @nimaltd and @d-serj ,

I solved the problem by increasing _ATC_SEARCH_CMD_MAX from 5 to 10.

The thing is in atc_command() function, there are these line:

    if (items >= _ATC_SEARCH_CMD_MAX)
      break;

in which the memory is allocated but it breaks before freeing.

I suggest you to free the memory before this break.

Also you might want to find a way to address this lack of number of _ATC_SEARCH_CMD_MAX.

Thank you for your interest.

Regards,
Ogulcan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants