This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gdb/175: smp + pthreads + breakpoints in FP code = corrupt FP state on x86



>Number:         175
>Category:       gdb
>Synopsis:       smp + pthreads + breakpoints in FP code = corrupt FP state on x86
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 13 15:38:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     ken@believe.com
>Release:        snapshot 2001-07-13
>Organization:
>Environment:
x86 linux, 2.2 or 2.4 SMP kernel. 
>Description:
When gdb is run on a program dynamically linked with pthreads on an SMP x86 linux system, setting a breakpoint
in a floating point computation, running until it's hit, and stepping or continuing over it causes a NaN (raw value 0xffc00000) to be produced instead of the correct value.  removing -lpthread or adding -static to the compile makes this problem go away.  The problem does not occur on a uniprocessor system.  The problem does not occur (even on SMP) using the official gdb-5.0 release.  The problem does not occur when only "step" or "stepi" are used instead of explicit breakpoints.  The problem also occurs when "next"ing over a function that returns a floating point value.

Here's the gdb run, the file, and how it was compiled:

GNU gdb 20010713 (MI_OUT)
Copyright 2001 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 "i686-pc-linux-gnu"...
(gdb) disas main
Dump of assembler code for function main:
0x8048450 <main>: push   %ebp
0x8048451 <main+1>: mov    %esp,%ebp
0x8048453 <main+3>: sub    $0x8,%esp
0x8048456 <main+6>: fildl  0x8(%ebp)
0x8048459 <main+9>: fld1   
0x804845b <main+11>: fsubrp %st,%st(1)
0x804845d <main+13>: fstps  0xfffffffc(%ebp)
0x8048460 <main+16>: mov    %ebp,%esp
0x8048462 <main+18>: pop    %ebp
0x8048463 <main+19>: ret    
End of assembler dump.
(gdb) b *0x8048460
Breakpoint 1 at 0x8048460: file float.c, line 7.
(gdb) b *0x804845b
Breakpoint 2 at 0x804845b: file float.c, line 6.
(gdb) run
Starting program: /home/ken/src/a.out 
[New Thread 1024 (LWP 14797)]
[Switching to Thread 1024 (LWP 14797)]

Breakpoint 2, 0x0804845b in main (argc=1, argv=0xbffff3cc) at float.c:6
6     f = (float)argc - 1.0;
(gdb) c
Continuing.

Breakpoint 1, main (argc=1, argv=0xbffff3cc) at float.c:7
7 }
(gdb) x/x &f
0xbffff354: 0xffc00000
(gdb) 


int
main( int argc, char **argv )
{
    float f;
    
    f = (float)argc - 1.0;
}

% gcc -pthread -g float.c

>How-To-Repeat:
extract the file from the description, compile it -lpthread or -pthread, and run gdb as shown in the description on an x86 SMP linux system.
>Fix:

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]