misc/174272: Segmentation Fault calling stat() from an application compiled as 32 bit on a 64 bit machine

Jerome St-Louis jerstlouis at gmail.com
Sat Dec 8 08:00:02 UTC 2012


>Number:         174272
>Category:       misc
>Synopsis:       Segmentation Fault calling stat() from an application compiled as 32 bit on a 64 bit machine
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 08 08:00:02 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Jerome St-Louis
>Release:        FreeBSD 9.0
>Organization:
Ecere Corporation
>Environment:
FreeBSD freebsd9-64 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:46:30 UTC 2012    root at farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
As summarized, invoking the stat() function from an application compiled with gcc -m32 on an amd64 install of FreeBSD 9.0 gives a segmentation fault.

What is up with that? Am I doing something wrong? Does FreeBSD not support compiling and running 32 bit applications on a 64 bit installation? Invoking stat() seems pretty basic functionality...

This is most disappointing as it prevents users from running our software on 64 bit versions of FreeBSD until we port  it to 64 bit.


Valgrind gives a warning:

Warning: client switching stacks?  SP change 0xfeffcca8 --> 0x39848928

And then...

Invalid read of size 4
   at 0x8048491: main (in /root/sdk/a.out)
 Address 0x39848928 is on thread 1's stack

Invalid read of size 4
   at 0xFeFFCD94: ???
 Address 0x0 is not stack'd, malloc'd or (recently) free'd

..

Many thanks!

Best regards,

Jerome
>How-To-Repeat:
Paste the following into bla.c:

#include <sys/stat.h>

int main()
{
   struct stat s;
   stat(argv[1], &s);
   return 0;
}

Compile with:
gcc -m32 bla.c

Run with:
./a.out

Observe:
Segmentation fault: 11 (core dumped)
>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list