Skip to content

avr-libc 1.6.4 dynamic memory (malloc, free) bug [imported] #857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cmaglie opened this issue Nov 15, 2012 · 3 comments
Closed

avr-libc 1.6.4 dynamic memory (malloc, free) bug [imported] #857

cmaglie opened this issue Nov 15, 2012 · 3 comments

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

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:

Forum topic which lead to this bug report:

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.

@madsci1016
Copy link

I am getting users of my libraries reporting multiple definition compile problems due to this addition of the memory allocation functions in the Arduino core conflicting with the same functions in avrclib. Sorry for double post on comit history, should have checked here first.

@madsci1016
Copy link

What the user reported:

c:/users/lbaynum/downloads/arduino-1.5.2-windows/arduino-1.5.2/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a(malloc.o): In function malloc’: (.text+0×0): multiple definition ofmalloc’
C:\Users\lbaynum\AppData\Local\Temp\build1657941011744485209.tmp/core.a(malloc.c.o):C:\Users\lbaynum\Downloads\arduino-1.5.2-windows\arduino-1.5.2\hardware\arduino\avr\cores\arduino/malloc.c:82: first defined here
c:/users/lbaynum/downloads/arduino-1.5.2-windows/arduino-1.5.2/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5\libc.a(malloc.o): In function free’: (.text+0×154): multiple definition offree’
C:\Users\lbaynum\AppData\Local\Temp\build1657941011744485209.tmp/core.a(malloc.c.o):C:\Users\lbaynum\Downloads\arduino-1.5.2-windows\arduino-1.5.2\hardware\arduino\avr\cores\arduino/malloc.c:194: first defined here

@madsci1016
Copy link

Nevermind, seems the problem is in the current version of SDFATLib. http://code.google.com/p/beta-lib/issues/detail?id=9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants