Bug 4688 - free()-ing a stack variable
Summary: free()-ing a stack variable
Status: RESOLVED WORKSFORME
Alias: None
Product: uClibc
Classification: Unclassified
Component: Standard Compliance (show other bugs)
Version: unspecified
Hardware: PC Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-12 15:38 UTC by Jonh Wendell
Modified: 2012-01-13 03:46 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
sample code that shows the issue (275 bytes, text/x-csrc)
2012-01-12 15:38 UTC, Jonh Wendell
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonh Wendell 2012-01-12 15:38:38 UTC
Created attachment 3962 [details]
sample code that shows the issue

we're supposed to not being able do free() a stack variable, but it seems it's possible with uclibc.

in the attached file, the program crashes on line 16, when using GLibc. It runs fine on uclibc.
Comment 1 Mike Frysinger 2012-01-13 03:46:53 UTC
uClibc's behavior is standards conforming.  from the spec:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/free.html

[...], if the argument does not match a pointer earlier returned by [...] malloc(), or if the space has been deallocated by a call to free() or realloc(), the behavior is undefined.

if you want to propose a debug option to add optional checking, then by all means.  but current uClibc behavior is not broken.