Bug 483801

Summary: receiving SIGTRAP from /lib/ld-linux.so.2 when using GDB in remotely debug
Product: Red Hat Enterprise Linux 5 Reporter: Amir <amir.hallajpour>
Component: gdbAssignee: Jan Kratochvil <jan.kratochvil>
Status: CLOSED NEXTRELEASE QA Contact: BaseOS QE <qe-baseos-auto>
Severity: high Docs Contact:
Priority: low    
Version: 5.1CC: cagney
Target Milestone: rc   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: kernel-PAE-2.6.18-92.el5.i686 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-02-12 23:05:35 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Amir 2009-02-03 17:42:39 UTC
Description of problem:
I am having a hard time getting GDB to work for remote debugging. I am running RedHat Enterprise Linux 5.1 (2.6.18-53.el5), gcc 4.1.2, and gdb 6.5-25.el5rh) on x86 platform. I do not generate any signals in my application and my application works fine. I am able to attach gdb to my remote process, but I never get to the breakpoints in the application becasue the program receives SIGTRAPS pretty much at every instruction when executing /bin/ld-linux.so.2

Version-Release number of selected component (if applicable):
RedHat Enterprise Linux 5.1 (2.6.18-53.el5), gcc 4.1.2, and gdb 6.5-25.el5rh) 

How reproducible:
The problem should be easily reproduciable.

Steps to Reproduce:
1.Build a C++ application that would require loading shared libraries at run-time.
2.Run gdbserver on the remote target board (gdbserver :<port> <executable>)
3. Run gdb debugger on the target:
gdb <exectuble>

gdb starts and then input the following commands in gdb:

target remote <target ip address>:<port>

enter "c" to continue executing the program.

Actual results:

GNU gdb Red Hat Linux (6.5-25.el5rh)
Copyright (C) 2006 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 "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". Here is what I get:

(gdb) target remote 192.168.10.110:2345
Remote debugging using 192.168.10.110:2345
0x0067e810 in ?? ()
(gdb) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x0068c793 in _dl_debug_state () from /lib/ld-linux.so.2
(gdb) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x0068c794 in _dl_debug_state () from /lib/ld-linux.so.2
(gdb) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x00681379 in dl_main () from /lib/ld-linux.so.2
(gdb) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x0068137f in dl_main () from /lib/ld-linux.so.2
(gdb) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x00681381 in dl_main () from /lib/ld-linux.so.2
(gdb) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x00681387 in dl_main () from /lib/ld-linux.so.2
(gdb) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x0068138d in dl_main () from /lib/ld-linux.so.2
(gdb)
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x00681397 in dl_main () from /lib/ld-linux.so.2
(gdb)
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x00681399 in dl_main () from /lib/ld-linux.so.2
(gdb)
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x0068139f in dl_main () from /lib/ld-linux.so.2
(gdb)
Continuing.


Expected results:
I execpt to receive SIGTRAP at breakpoints in my application, but the debugger catches SIGTRAP in the gcc loader.

Additional info:
It seems like SIGTRAP is generated at every instruction in ld-linux.so

Comment 1 Jan Kratochvil 2009-02-12 23:05:35 UTC
Successfully reproduced the problem on RHEL-5.1, therefore:
kernel-PAE-2.6.18-53.el5.i686
gdb-6.5-25.el5.i386

Verified the problem as fixed on RHEL-5.2, tried upgrading just the kernel:
kernel-PAE-2.6.18-92.el5.i686
gdb-6.5-25.el5.i386

Still you should rather run full RHEL-5.2 to get a Red Hat supported product.

RHEL-5.2 kernel had many utrace/ptrace fixes which explain this Bug.