Bug 524572 - non-matching build-id libraries should not be loaded for `gdb -c'
Summary: non-matching build-id libraries should not be loaded for `gdb -c'
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: gdb
Version: rawhide
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Jan Kratochvil
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 525721
TreeView+ depends on / blocked
 
Reported: 2009-09-21 09:14 UTC by Jan Kratochvil
Modified: 2009-09-25 11:47 UTC (History)
2 users (show)

Fixed In Version: gdb-6.8.91.20090925-2.fc12
Clone Of:
Environment:
Last Closed: 2009-09-25 11:09:09 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Jan Kratochvil 2009-09-21 09:14:18 UTC
Description of problem:
When some on-disk libraries have non-matching build-id (either for their binary or for their .debug file) GDB will currently load them just according to their name (with some complaint).
During `gdb -c' mode (or `core-file' command with no symbols loaded) the build-ids should be followed strictly to prevent bogus backtraces for bugreports.

Version-Release number of selected component (if applicable):
gdb-6.8.91.20090917-2.fc12.x86_64

How reproducible:
Always.

Steps to Reproduce:
cd to en empty directory
rm -rf lib.so main .build-id core.*; echo -e '#include<signal.h>\nvoid lib(void){raise(SIGSEGV);}' | gcc -o lib.so -shared -fPIC -Wall -ggdb2 -x c -; echo -e '#include<unistd.h>\n\nint main(void){sleep(1);void lib(void);lib();return 0;}' | gcc -o main -Wall -ggdb2 ./lib.so -x c -;function bid { objdump -s -j .note.gnu.build-id $1 | sed -n '6,7s/^ *[^ ]\+ \+\(.\{35\}\) .*$/\1/p' | tr -d ' \n' | sed 's#^\(..\)\(.*\)#.build-id/\1/\2#'; }; function link { b=`bid $1`; mkdir -p `dirname $b`; ln -s $1 $b; ln -s $1 $b.debug; }; link $PWD/main; link $PWD/lib.so; (ulimit -c unlimited; ./main &); echo 'void file(void){}' | gcc -o lib.so -shared -fPIC -Wall -ggdb2 -x c -; sleep 2; gdb -nx -ex 'set debug-file-directory .' -ex "core-file `echo ./core.*`" -ex bt -ex q

Actual results:
[...]
warning: File "/tmp/coredir/lib.so" has a different build-id, file skipped
Missing separate debuginfo for ./lib.so
[...]
Program terminated with signal 11, Segmentation fault.
#0  0x000000312d033575 in raise () from /lib64/libc.so.6
#0  0x000000312d033575 in raise () from /lib64/libc.so.6
#1  0x00007f7aff57c57a in _fini () from ./lib.so
#2  0x00007fffd1907390 in ?? ()
#3  0x0000000000400617 in main () at <stdin>:3

Expected results:
[...]
warning: File "/tmp/coredir/lib.so" has a different build-id, file skipped
Missing separate debuginfo for ./lib.so
[...]
Program terminated with signal 11, Segmentation fault.
#0  0x000000312d033575 in raise () from /lib64/libc.so.6
#0  0x000000312d033575 in raise () from /lib64/libc.so.6
#1  0x00007f7aff57c57a in ?? ()
#2  0x00007fffd1907390 in ?? ()
#3  0x0000000000400617 in main () at <stdin>:3

Additional info:

Comment 1 Jan Kratochvil 2009-09-25 11:09:09 UTC
rm -rf lib.so main /tmp/lib/debug core.*; mkdir -p /tmp/lib/debug; cp -a /usr/lib/debug/.build-id /tmp/lib/debug/.build-id; for i in /usr/lib/debug/*; do ln -s $i /tmp/lib/debug/`basename $i`; done; echo -e '#include<signal.h>\nvoid lib(void){raise(SIGSEGV);}' | gcc -o lib.so -shared -fPIC -Wall -ggdb2 -x c -; echo -e '#include<unistd.h>\n\nint main(void){sleep(1);void lib(void);lib();return 0;}' | gcc -o main -Wall -ggdb2 ./lib.so -x c -;function bid { objdump -s -j .note.gnu.build-id $1 | sed -n '6,7s/^ *[^ ]\+ \+\(.\{35\}\) .*$/\1/p' | tr -d ' \n' | sed 's#^\(..\)\(.*\)#/tmp/lib/debug/.build-id/\1/\2#'; }; function link { b=`bid $1`; mkdir -p `dirname $b`; ln -s $1 $b; ln -s $1 $b.debug; }; link $PWD/main; link $PWD/lib.so; (ulimit -c unlimited; ./main &); echo 'void file(void){}' | gcc -o lib.so -shared -fPIC -Wall -ggdb2 -x c -; sleep 2; .../gdb -nx -ex 'set debug-file-directory /tmp/lib/debug' -ex "core-file `echo ./core.*`" -ex bt -ex q 

before:
Program terminated with signal 11, Segmentation fault.
#0  0x00000036b5a332f5 in *__GI_raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64	  return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
Current language:  auto; currently minimal
#0  0x00000036b5a332f5 in *__GI_raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007f0f6a91c57a in _fini () from ./lib.so
#2  0x00007fffa8e5e160 in ?? ()
#3  0x0000000000400617 in main () at <stdin>:3

after:
Program terminated with signal 11, Segmentation fault.
#0  0x00000036b5a332f5 in raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64	  return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
#0  0x00000036b5a332f5 in raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007f1390d3757a in ?? ()
#2  0x00007fffabd06080 in ?? ()
#3  0x0000000000400617 in main () at <stdin>:3


Note You need to log in before you can comment on or make changes to this bug.