run-parts segfaults with gcc 4.5.0

walter harms wharms at bfs.de
Mon May 10 10:49:18 UTC 2010



Thierry Reding schrieb:
> * walter harms wrote:
>>
>> Thierry Reding schrieb:
>>> Hi,
>>>
>>> After upgrading gcc to 4.5.0, I get segfaults when running the run-parts
>>> applet. The segfault happens in bb_alphasort() during the calls to strcmp().
>>> I debugged this and saw that the pointers passed into strcmp() were both
>>> NULL. Apparently this comes from the act() function, which for some reason
>>> overwrites the elements of the names array. Oddly enough, when I print that
>>> same array at the end of each call to act() the segfault disappears.
>>>
>>> FWIW, I came up with the following patch that fixes things, though it is
>>> probably not the preferred way for busybox because it removes the names
>>> variable from the global storage.
>>>
>> from gcc 4.5.0 changes:
>> "There is a new optimization pass that attempts to change prototype of functions to avoid unused parameters, pass only relevant parts of
>> structures and turn arguments passed by reference to arguments passed by value when possible. It is enabled by -O2 and above as well as -Os and
>> can be manually invoked using the new command-line switch -fipa-sra. "
>>
>> Since BB uses -Os as default, perhaps you can remove it and test again ?
> 
> Configuring busybox with CONFIG_DEBUG=y and CONFIG_DEBUG_PESSIMIZE=y fixes
> the segfault. Setting those two variables seems the canonical way to tell
> busybox to build with -O0.
> 

so its a gcc bug, welcome to the club, did you already report it ?

re,
 wh



More information about the busybox mailing list