Bug 4688

Summary: free()-ing a stack variable
Product: uClibc Reporter: Jonh Wendell <jonh.wendell>
Component: Standard ComplianceAssignee: unassigned
Status: RESOLVED WORKSFORME    
Severity: normal CC: uclibc-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:
Attachments: sample code that shows the issue

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.