mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-21 01:12:32 +08:00
f3eee58617
A GDB crash was discovered on Fedora GDB that was tracked back to an issue with the way that debuginfod is cleaned up. The bug was reported on Fedora 37, 38, and 39. Here are the steps to reproduce: 1. The file /etc/ssl/openssl.cnf contains the following lines: [provider_sect] default = default_sect ##legacy = legacy_sect ## [default_sect] activate = 1 ##[legacy_sect] ##activate = 1 The bug will occur when the '##' characters are removed so that the lines in question look like this: [provider_sect] default = default_sect legacy = legacy_sect [default_sect] activate = 1 [legacy_sect] activate = 1 2. Clean up any existing debuginfod cache data: > rm -rf $HOME/.cache/debuginfod_client 3. Run GDB: > gdb -nx -q -iex 'set trace-commands on' \ -iex 'set debuginfod enabled on' \ -iex 'set confirm off' \ -ex 'start' -ex 'quit' /bin/ls +set debuginfod enabled on +set confirm off Reading symbols from /bin/ls... Downloading separate debug info for /usr/bin/ls ... snip ... Temporary breakpoint 1, main (argc=1, argv=0x7fffffffde38) at ../src/ls.c:1646 1646 { +quit Fatal signal: Segmentation fault ----- Backtrace ----- ... snip ... So GDB ends up crashing during exit. What's happening is that when debuginfod is initialised debuginfod_begin is called (this is in the debuginfod library), this in turn sets up libcurl, which makes use of openssl. Somewhere during this setup process an at_exit function is registered to cleanup some state. Back in GDB the debuginfod_client object is managed using this code: /* Deleter for a debuginfod_client. */ struct debuginfod_client_deleter { void operator() (debuginfod_client *c) { debuginfod_end (c); } }; using debuginfod_client_up = std::unique_ptr<debuginfod_client, debuginfod_client_deleter>; And then a global debuginfod_client_up is created to hold a pointer to the debuginfod_client object. As a global this will be cleaned up using the standard C++ global object destructor mechanism, which is run after the at_exit handlers. However, it is expected that when debuginfod_end is called the debuginfod_client object will still be in a usable state, that is, we don't expect the at_exit handlers to have run and started cleaning up the library state. To fix this issue we need to ensure that debuginfod_end is called before the at_exit handlers have a chance to run. This commit removes the debuginfod_client_up type, and instead has GDB hold a raw pointer to the debuginfod_client object. We then make use of GDB's make_final_cleanup to register a function that will call debuginfod_end. As GDB's final cleanups are called before exit is called, this means that debuginfod_end will be called before the at_exit handlers are called, and the crash identified above is resolved. It's not obvious how this issue can easily be tested for. The bug does not appear to manifest when using a local debuginfod server, so we'd need to setup something more involved. For now I'm proposing this patch without any associated tests. Co-Authored-By: Mark Wielaard <mark@klomp.org> Co-Authored-By: Simon Marchi <simark@simark.ca> Reviewed-By: Tom Tromey <tom@tromey.com> Reviewed-By: Aaron Merey <amerey@redhat.com> |
||
---|---|---|
bfd | ||
binutils | ||
config | ||
contrib | ||
cpu | ||
elfcpp | ||
etc | ||
gas | ||
gdb | ||
gdbserver | ||
gdbsupport | ||
gnulib | ||
gold | ||
gprof | ||
gprofng | ||
include | ||
intl | ||
ld | ||
libbacktrace | ||
libctf | ||
libdecnumber | ||
libiberty | ||
libsframe | ||
opcodes | ||
readline | ||
sim | ||
texinfo | ||
zlib | ||
.cvsignore | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
ar-lib | ||
ChangeLog | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING3 | ||
COPYING3.LIB | ||
COPYING.LIB | ||
COPYING.LIBGLOSS | ||
COPYING.NEWLIB | ||
depcomp | ||
djunpack.bat | ||
install-sh | ||
libtool.m4 | ||
lt~obsolete.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
makefile.vms | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
multilib.am | ||
README | ||
README-maintainer-mode | ||
SECURITY.txt | ||
setup.com | ||
src-release.sh | ||
symlink-tree | ||
test-driver | ||
ylwrap |
README for GNU development tools This directory contains various GNU compilers, assemblers, linkers, debuggers, etc., plus their support routines, definitions, and documentation. If you are receiving this as part of a GDB release, see the file gdb/README. If with a binutils release, see binutils/README; if with a libg++ release, see libg++/README, etc. That'll give you info about this package -- supported targets, how to use it, how to report bugs, etc. It is now possible to automatically configure and build a variety of tools with one command. To build all of the tools contained herein, run the ``configure'' script here, e.g.: ./configure make To install them (by default in /usr/local/bin, /usr/local/lib, etc), then do: make install (If the configure script can't determine your type of computer, give it the name as an argument, for instance ``./configure sun4''. You can use the script ``config.sub'' to test whether a name is recognized; if it is, config.sub translates it to a triplet specifying CPU, vendor, and OS.) If you have more than one compiler on your system, it is often best to explicitly set CC in the environment before running configure, and to also set CC when running make. For example (assuming sh/bash/ksh): CC=gcc ./configure make A similar example using csh: setenv CC gcc ./configure make Much of the code and documentation enclosed is copyright by the Free Software Foundation, Inc. See the file COPYING or COPYING.LIB in the various directories, for a description of the GNU General Public License terms under which you can copy the files. REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info on where and how to report problems.