Bug 127397

Summary: [amd64] 32bit application on FreeBSD-6.3 amd64 gets SIGBUS
Product: Base System Reporter: Chitti Nimmagadda <Chitti.Nimmagadda>
Component: amd64Assignee: freebsd-amd64 (Nobody) <amd64>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Chitti Nimmagadda 2008-09-15 14:30:01 UTC
I'm running a 32bit application on amd64 FreeBSD-6.3 and the application
is getting a SIGBUS. 

The issue can be reproduced with the following test program "foo.c"
====
main()
{
        char c1;
        static int a;
        static int b;
        static int c;
        int d;

        while(1) {
                a = b;
                b = c;
                c = a;
        }
}
====

The program is compiled using the following command:
gcc -g -m32 -L/usr/lib32 -B/usr/lib32 -o foo foo.c

following is the info from gdb
==
freebsd64bit# ./foo
^C
freebsd64bit# ./foo
^C
freebsd64bit# ./foo
^C
freebsd64bit# ./foo
Bus error (core dumped)
freebsd64bit# gdb -c foo.core foo
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
Core was generated by `foo'.
Program terminated with signal 10, Bus error.
Reading symbols from /usr/lib32/libc.so.6...done.
Loaded symbols for /usr/lib32/libc.so.6
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x08048501 in main () at foo.c:10
10                      a = b;
(gdb) x/i 0x08048501
0x8048501 <main+33>:    mov    %eax,0x80496dc
(gdb)
==

system details:
OS 6.3 FreeBSD amd64
CPU: Intel(R) Xeon(R) CPU X5355  @ 2.66GHz (2666.78-MHz K8-class CPU)
Memory: 16GB

The issue is reproducible only on the SMP kernel.

This issue is not reproducible all the times, but occurs more frequently
within the first 5mins after the machine is booted (after the login prompt)

Any solution or workaround exist for this issue?

Thanks,
Chitti.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2008-09-16 03:53:06 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-amd64

With a little bit of hesitation, move this one over to the amd64 category, 
in hopes that it will be a little more high-profile there.
Comment 2 chittir 2008-09-19 10:41:33 UTC
Setting the PCB_32BIT flag in pcb_flags(file sys/amd64/ia32/ia32_signal.c,
line 760) is resolving the issue
Comment 3 Alexander Best freebsd_committer freebsd_triage 2010-11-13 18:37:25 UTC
State Changed
From-To: open->closed

Fixed in HEAD and 8.x (r180992) and MFC'ed to 7.x (r181752). I can confirm that 
the example application compiled with the according gcc line to produce a 32bit 
binary no longer crashes with SIGBUS. 
Since 6.x went EoL: close this PR.