[PATCH v2 0/2] Fix regression with lazy-loading of partial symbols

Lancelot SIX lancelot.six@amd.com
Thu May 19 18:45:55 GMT 2022


This series is a V2 for https://sourceware.org/pipermail/gdb-patches/2022-April/188385.html.

Since V1:

- Instead of only changing cooked_index_functions::expand_symtabs_matching,
  change objfile so each call to a method of a quick_function is done after
  ensuring the partial symbols have been read (the exception being the methods
  used to actually read partial symbols).
- Added patch #2 which does some cleanup in
  psymbol_functions::require_partial_symbols.
- Addressed Pedro's comments regarding the testcase.

All feedback are welcome.

Best,
Lancelot.

---

The recent DWARF indexer rewrite introduced a regression when debugging
a forking program.

Here is a way to reproduce the issue (there might be other ways, but one
is enough and this one mimics the situation we encountered).  Consider a
program which forks, and the child loads a shared library and calls a
function in this shared library:

    if (fork () == 0)
      {
        void *solib = dlopen (some_solib, RTLD_NOW);
        void (*foo) () = dlsym (some_solib, "foo");
        foo ();
      }

Suppose that this program is compiled without debug info, but the shared
library it loads has debug info enabled.

When debugging such program with the following options:

  - set detach-on-fork off
  - set follow-fork-mode child

we see something like:

    (gdb) b foo
    Function "foo" not defined.
    Make breakpoint pending on future shared library load? (y or [n]) y
    Breakpoint 1 (foo) pending.
    (gdb) run
    Starting program: a.out
    [Attaching after process 19720 fork to child process 19723]
    [New inferior 2 (process 19723)]
    [Switching to process 19723]

    Thread 2.1 "a.out" hit Breakpoint 1, 0x00007ffff7fc3101 in foo () from .../libfoo.so
    (gdb) list

    Fatal signal: Segmentation fault
    ----- Backtrace -----
    [...]
    ---------------------

Lancelot SIX (2):
  gdb: Require psymtab before calling quick_functions in objfile
  gdb: Simplify psymbol_functions::require_partial_symbols

 gdb/objfiles.h                                | 10 ++++
 gdb/psymtab.c                                 |  2 +-
 gdb/symfile-debug.c                           | 30 +++++-----
 ...fork-no-detach-follow-child-dlopen-shlib.c | 23 ++++++++
 .../fork-no-detach-follow-child-dlopen.c      | 40 +++++++++++++
 .../fork-no-detach-follow-child-dlopen.exp    | 57 +++++++++++++++++++
 6 files changed, 146 insertions(+), 16 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen-shlib.c
 create mode 100644 gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.c
 create mode 100644 gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp


base-commit: c4dd8eb523fae5c9d312f4b7b21377eec66e70c3
-- 
2.25.1



More information about the Gdb-patches mailing list