Content originally posted in LPCWare by robertpalmerjr on Wed Jan 14 10:47:08 MST 2015
Ok, I obviously can't send my main project, but I will try to pare it down to something very short that I can post.
I am using LPCXpresso 5.4.2, again, because of the certification issue. Can you provide any info on the bug. What I'm seeing is that malloc appears to add 3 to the requested byte count and then divide by 4, I assume to get number of 32bit words. It then does, what appears to be a loop check, which fails. When the loop check fails, it adds 12 to the originally requested amount (192 + 12 = 204 bytes) and calls _sbrk which then calls __check_heap_overflow which fails. Check heap first compares the stack pointer to the current top of heap, then to the top of heap AFTER adding the requested allocation. This is where the failure is happening. The first compare is successful, the second is not.
It seems that the heap or stack is not allocated correctly or is being tested incorrectly.
I found an issue about this in the forums, but that seemed to be related only to freeRTOS