2020-01-15 05:38 PM
I use "sprintf (string,"comment"); everywhere
now for some reason, I am getting a hardfault. in an innocuous print.
length += sprintf(String + length, "Received Packet from ");
length is only 15.
String is declared as
char String[256];
I guess it is using malloc,
How do we check the allocations are being cleared ?
I never use malloc anywhere, so its not me...
2020-01-17 02:37 AM
As you know, I'm not a big fan of the VS or GNU/GCC
With heap analysis there are several approaches, one is to understand the linked list and allocation method hidden below the pointer handed to you, another is wrap the malloc/free adding your own structure, tracking size and alloc/free counts so you can identify imbalances, leaks and orphans. On the free side you want to track if the same memory allocation is freed more than once. And filling the released memory with an invalidating pattern liable to fault quickly, ie 0xCDCDCDCD, and be recognizable as such.
You'd need to look into and understand the implementation details of your chosen toolset.
The failure in other places suggests a deeper underlying issue.
Lacking trace, add a lot of sanity checking to pointers, stack depth checks, and instrumentation, to confine the problem and identify failure conditions quickly so the culprits more readily pinpointed.
2020-01-17 03:26 AM
will check for VisualStudio's malloc implementation,
would like to work a function to check stack/heap levels / leaks and Freeing the same memory multiple times.