Bug 130423

Summary: gdb can't debug pie when attaching to process
Product: [Fedora] Fedora Reporter: Joe Orton <jorton>
Component: gdbAssignee: Jan Kratochvil <jan.kratochvil>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: cagney, goeran, pertusus, redhat-bugzilla
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gdb-6.6-2.fc7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-01-31 01:04:28 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:
Bug Depends On: 150591    
Bug Blocks: 136451    

Description Joe Orton 2004-08-20 13:11:34 UTC
Linux trash.cambridge.redhat.com 2.6.7-1.478 #1 Thu Jul 8 15:02:38 EDT
2004 i686 i686 i386 GNU/Linux

[root@trash root]# rpm -q httpd gdb httpd-debuginfo
httpd-2.0.50-4
gdb-6.1post-1.20040607.8
httpd-debuginfo-2.0.50-4
[root@trash root]# gdb /usr/sbin/httpd
GNU gdb Red Hat Linux (6.1post-1.20040607.8rh)
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 "i386-redhat-linux-gnu"...Using host
libthread_db library "/lib/tls/libthread_db.so.1".
 
(gdb) break main
Breakpoint 1 at 0x1c8fb: file
/usr/src/debug/httpd-2.0.50/server/main.c, line 365.
(gdb) run -X
Starting program: /usr/sbin/httpd -X
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x1c8fb: Input/output error.
 
(gdb)

OR

[root@trash root]# gdb /usr/sbin/httpd 7626
GNU gdb Red Hat Linux (6.1post-1.20040607.8rh)
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 "i386-redhat-linux-gnu"...Using host
libthread_db library "/lib/tls/libthread_db.so.1".
 
Attaching to program: /usr/sbin/httpd, process 7626
0x00f08402 in ?? ()
(gdb) where
#0  0x00f08402 in ?? ()
#1  0x006baa7b in ?? ()
#2  0x0071dff8 in ?? ()
#3  0x00579294 in ?? ()
#4  0x005797bc in ?? ()
#5  0x09834d80 in ?? ()
#6  0xfeed51b8 in ?? ()
#7  0x00571b47 in ?? ()
#8  0x00100001 in ?? ()
#9  0x005797bc in ?? ()
#10 0x00000001 in ?? ()
#11 0x00533cd0 in ?? ()
#12 0x098bfec0 in ?? ()
#13 0xfeed521c in ?? ()
#14 0xfeed51c8 in ?? ()
#15 0x0057245e in ?? ()
#16 0x09834d80 in ?? ()
#17 0x003d74b0 in ?? ()
#18 0xfeed5238 in ?? ()
#19 0x0050b716 in ?? ()
#20 0x09834d80 in ?? ()
#21 0x00000002 in ?? ()
#22 0x00000000 in ?? ()
#23 0x00000000 in ?? ()

Comment 1 Elena Zannoni 2004-08-23 18:48:30 UTC
hmmm, can you try
6.1post-1.20040607.22?

I don't remember if I had the pie fixes in the .8 rpm.


Comment 2 Joe Orton 2004-08-24 08:55:05 UTC
I can break on main when starting a fresh gdb with that version.

Attaching to the running httpd is still not giving a good backtrace,
though:

(gdb) where
#0  0x00ee6402 in __kernel_vsyscall ()
#1  0x003a3a7b in semop () from /lib/tls/libc.so.6
#2  0x0058c6b8 in ?? () from /usr/lib/libapr-0.so.0
#3  0x0058cbf4 in initialized () from /usr/lib/libapr-0.so.0
#4  0x09bdbde0 in ?? ()
#5  0xfef1fb68 in ?? ()
#6  0x00584f36 in proc_mutex_sysv_acquire (mutex=0x58cbf4) at
proc_mutex.c:263
Previous frame inner to this frame (corrupt stack?)


Comment 3 Elena Zannoni 2004-08-27 19:34:14 UTC
Yes, atttaching to a pie executable doesn't work. It's a design
limitation, there needs to be work done in bfd. We have a fix in
progress in the FSF tree, but the binutils people didn't like it. So
it's stalling.

But if you don't attach (i.e. run under gdb from the beginning) it
should work.

Comment 4 Elena Zannoni 2004-08-27 19:37:24 UTC
modified summary and assign to Andrew, since he was doing the bfd part.
Maybe we can get a RH only patch to put in the rpm.

Comment 5 Patrice Dumas 2005-06-22 07:53:51 UTC
I can't get a backtrace when following a child. Is it the same issue ?

[dumas@chapelle bug_reports]$ gdb gfortran
GNU gdb Red Hat Linux (6.3.0.0-1.24rh)
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 "i386-redhat-linux-gnu"...Using host libthread_db
library "/lib/libthread_db.so.1".

(gdb)  set follow-fork-mode child
(gdb)  run -c -o truc.o cqm.f
Starting program: /usr/bin/gfortran -c -o truc.o cqm.f
Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0x622000
Attaching after fork to child process 25703.

Program received signal SIGSEGV, Segmentation fault.
[Switching to process 25703]
0x0809caf2 in ?? ()
(gdb) bt
#0  0x0809caf2 in ?? ()
#1  0x00000000 in ?? ()
(gdb) 

Comment 6 Patrice Dumas 2006-09-27 13:10:21 UTC
I have tried to reproduce comment #2 with gdb in devel.
It may be right now since I get:

(gdb) where
#0  0xb7fb0402 in __kernel_vsyscall ()
#1  0x0020eecd in ___newselect_nocancel () from /lib/libc.so.6
#2  0x00e7ad59 in apr_sleep () from /usr/lib/libapr-1.so.0
#3  0x00ce0086 in ap_wait_or_timeout (status=0xbfe55f94, exitcode=0xbfe55f90, 
    ret=0xbfe55f80, p=0x96564f8)
    at /usr/src/debug/httpd-2.2.3/server/mpm_common.c:345
#4  0x00cea0a3 in ap_mpm_run (_pconf=0x96564f8, plog=0x96845b0, s=0x9658398)
    at /usr/src/debug/httpd-2.2.3/server/mpm/prefork/prefork.c:1007
#5  0x00cc11b7 in main (argc=157631856, argv=0x0)
    at /usr/src/debug/httpd-2.2.3/server/main.c:717


Comment 7 Patrice Dumas 2006-10-20 20:03:02 UTC
Shouldn't this bug be closed?

Comment 8 Jan Kratochvil 2007-01-14 17:33:56 UTC
I got a backtrace failure of "-fpie -pie" compiled executable.
There is a new `gdb.base/bt-ppc.exp' testcase for it.
To be evaluated more.


Comment 9 Jan Kratochvil 2007-01-31 01:04:28 UTC
It was most probably fixed much earlier than the verification for `gdb-6.6-2.fc7'.
"-fpie -pie" case presented in Comment 8 is unrelated.
The appropriate testcase for this Bug is now `gdb.base/bt-ppc.exp'.