I have an application that is running on an ARM9 and compiled with V3.60. It uses RL. I am having a strange problem. We are really close to the maximum amount of memory on our processor, within 2K. During development, I declared an unsigned char array of size 1056 with global scope in one of the libraries that handles data packets that are received.
#include <91x_conf.h> #include <91x_lib.H> #include <RTL.h> #include <string.h>
U8 my_buffer[1056];
I changed my implementation later and no longer needed that array.
Now, here is the strange part.
Task1 cannot handle large packets without that array declaration being present. If I comment the array declaration out or cut the size in half, the first large packet (~1076 bytes) that comes in crashes the entire application, though it works as long as the packets received over Task1's interface are small. Another weird thing is that Task2 is unable to properly receive data if I leave the array declaration in my code, yet it works if I leave the declaration out.
Task1 and Task2 both claim between 2-3K of allocated blocks of memory on the heap when they start, and those blocks are not reallocated or deallocated until the board is rebooted.
Any ideas what is going on here?
Task1 cannot handle large packets without that array declaration being present.
That nearly certainly means that your "Task1" contains a massive buffer overflow that currently just so happens to overflow into that supposedly "unused" buffer. Take away the buffer, and you overflow into some other variables --- ka-BOOM.
To test if this is your root cause, write a recognizable pattern you wouldn't have in any of your data (customary choices include repetetions of 0xDEADBEEF), execute a test sequence that's known to trigger the crash if the buffer is absent, then inspect the buffer. Is your tell-tale pattern still intact? Or does it, by any chance, hold content of that big data package (or derived from that)?
... as the others have already said.
Another possible way to catch such a problem is to set a data-write breakpoint in the supposedly "unused" array...