Description
This is Issue 857 moved from a Google Code project.
Added by 2012-03-12T01:31:54.000Z by jbrazio.
Please review that bug for more context and additional comments, but update this bug.
Original labels: Type-Defect, Priority-High, Milestone-1.0.2, Component-Core, Component-Build
Original description
Arduino 1.0 uses WinAVR-20081205 that comes with avr-libc 1.6.4.
There is a documented bug on avr-libc (#27235, #28135) related with malloc() and free() that affects the current avr-libc version used by arduino; WinAVR-20100110's avr-libc 1.6.7 is still affected. Proven not to be affected is Atmel's native libc from AVR Studio 5.1.208 and wiring's avr-libc 1.7.1.
The solution would be to update arduino's avr-libc from 1.6.4 to the latest 1.7 branch.
Attached is a program to prove the bug existence, when run it outputs used/free/large after each allocation call, then repeats the test when doing de-allocation. The expected behavior is at the end of the program the amount of used/free/large to be the same as at the start.. which is not the case using arduino's avr-libc 1.6.4. The original code comes from Andy Brown (http://j.mp/yGnTwT) I have just ported it to compile under Arduino's IDE.
Links:
- bug #27235: malloc: Several things go wrong (http://j.mp/xq8Xk8)
- bug #28135: malloc(): expand the last free chunk when expanding __brkval (http://j.mp/zQfOWN)
Forum topic which lead to this bug report:
- malloc(), realloc().. the dark side powerful it is (http://j.mp/y3YKF6)
Note: Nick Gammon mentioned that since Strings uses malloc() and free() this could be the explanation for some people complaining about random program crash when using the library.