I have a VERY odd problem. I am using SYSBIOS 6_34_02_18 built with code composer 5.3 and all of its associated latest versions of XDC, compilers, etc built for an ARM9 platform on a OMAP-L138.
I have exceptions turned off in every way I can figure out (building a custom bios with assertsEnabled=false, setting Main.common$.diags_ASSERT, Main.common$.diags_INTERNAL, and Defaults.common$.diags_ASSERT to DIAGS.ALWAYS_OFF).
If I invoke malloc with a very large number (3083855848) in my main function, I get a print out
ti.sysbios.heaps.HeapMem: line 307: out of memory: handle=0xc11bf728, size=3083855856
and the function returns NULL. I'd prefer no printout, but this is fine.
BUT, when I invoke malloc with that same number in library linked to by my main application, I get an assertion! I have absolutely no explanation for the mechanism for this. How could malloc in my main be different than malloc in my library? Poking around with break points, both mallocs get resolved to the malloc in my generated configPkg/package/cfg/st_pe9.c file, but in the main we get the print out, and in the library there is an assertion that seems (If I copy and past the PC,LR,and PC registers into the registers view) to be getting thrown from line 270 of HeapMem.c with an illegal memory access, i.e., it dies at a random line in the file,
if (remainSize) {
newHeader = (HeapMem_Header *)
((Memory_Size)allocAddr + adjSize);
newHeader->next = curHeader->next; ---> seems to die here
newHeader->size = remainSize;
curHeader->next = newHeader;
}
This is an utter disaster, as it brings my application to an unrecoverable halt in the field. Any ideas of even how I can formulate a rational question on this?
By the way, I did observe that if I call malloc(0xFFFFFFFF), then the sizeof a small structure gets added to this and silently wraps around to successfully and erroneously create a very small buffer. I'm thinking this is a bug that could potentially cause me some significant problems (since 0xFFFFFFFF is what you get when you read uninitialized flash memory, and the 3rd party code I am using reads in a "size" value from flash and depends on malloc to return NULL in the case of crazy big numbers).
Jay