Bug 22995 - crash when backtrace includes a removed shared object
Summary: crash when backtrace includes a removed shared object
Status: RESOLVED DUPLICATE of bug 16577
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 8.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2018-03-22 14:10 UTC by Emiliano Testa
Modified: 2018-03-31 12:22 UTC (History)
4 users (show)

See Also:
Last reconfirmed:

Reproducer for the issue. (593 bytes, application/gzip)
2018-03-22 14:10 UTC, Emiliano Testa

Note You need to log in before you can comment on or make changes to this bug.
Description Emiliano Testa 2018-03-22 14:10:48 UTC
Created attachment 10910 [details]
Reproducer for the issue.

I am using gdb-8.1 and I have a test (attached) that makes GDB crash under the following scenario:

1) compile the test:

$ gcc -o test5085 test5085.c -ldl
$ gcc -c -fpic test5085_lib.c
$ gcc -shared -o test5085_64_lib.so test5085_lib.o

then load it in gdb:

$ gdb test5085


Python Exception <type 'exceptions.ImportError'> No module named gdb:
/home/etesta/tmp/gdb81_build/gdb/gdb: warning:
Could not load the Python gdb module from `/usr/local/share/gdb/python'.
Limited Python support is available from the _gdb module.
Suggest passing --data-directory=/path/to/gdb/data-directory.

GNU gdb (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./test5085...(no debugging symbols found)...done.

(gdb) break dlsym

Breakpoint 1 at 0x4005e0

(gdb) r ./test5085_64_lib.so

Starting program: /home/etesta/tmp/test5085/test5085 ./test5085_64_lib.so

Breakpoint 1, Python Exception <type 'exceptions.NameError'> Installation error: gdb.execute_unwinders function is missing:
0x00007ffff7bd4040 in dlsym () from /lib/x86_64-linux-gnu/libdl.so.2

AT THIS POINT REMOVE OR MOVE test5058_64_lib.so

(gdb) c


Program received signal SIGSEGV, Segmentation fault.
Python Exception <type 'exceptions.NameError'> Installation error: gdb.execute_unwinders function is missing:
BFD: reopening ./test5085_64_lib.so: No such file or directory

BFD: reopening ./test5085_64_lib.so: No such file or directory

(gdb) bt

Segmentation fault (core dumped)

I did a bit of investigation and I noticed that with this issue was already reported a while back and it was fixed with:

commit 938f0e2f6766e90a5ddc5df00e97a68873fd1252
Author: Andrew Burgess <aburgess@broadcom.com>
Date:   Wed Apr 2 17:02:51 2014 +0100

   Remove previous frame if an error occurs when computing frame id during unwind.

but then broken by:

commit f245535cf583ae4ca13b10d47b3c7d3334593ece
Author: Pedro Alves <palves@redhat.com>
Date:   Mon Sep 5 18:41:38 2016 +0100

    Fix PR19927: Avoid unwinder recursion if sniffer uses calls parse_and_eval

I keep getting a build failure with the latest git commit on master, so I didn't try with the latest code.

I am available should you need any more information.
Comment 1 Andrey Utkin 2018-03-22 21:51:31 UTC
We have just found this is fixed in git master by commit 416675305692976aca45860e24b963982a2e682a ("Fix gdb segv when objfile can't be opened"). Thanks to Mike Gulick who authored the patch!

I think gdb-8.1-branch might benefit from picking that commit.
Comment 2 Simon Marchi 2018-03-24 22:15:39 UTC
Closing as a duplicate.  If you'd like to have it cherry-picked to 8.1, feel free to propose it on the mailing list (you can reply to the original patch thread).

*** This bug has been marked as a duplicate of bug 16577 ***