public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Jacob Kroon via Gdb <gdb@sourceware.org>
Subject: Re: Debugging ld.so in gdb
Date: Fri, 04 Feb 2022 14:58:26 +0100	[thread overview]
Message-ID: <8735kypwcd.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <29e0ef71-4706-9b0f-2a68-e12c54120d8e@gmail.com> (Jacob Kroon via Gdb's message of "Fri, 4 Feb 2022 14:45:33 +0100")

* Jacob Kroon via Gdb:

> Since a week or two I have started to see a segfault on my updated
> Fedora 35 system. I suspect the segfault is related to a recent glibc
> update.
>
> The segfault I see happens when I run the following:
>
> $ ldd ./mylib.so
>
> I narrowed it down to running:
>
> $ LD_TRACE_LOADED_OBJECTS=1 /lib64/ld-linux-x86-64.so.2 ./mylib.so
>
> "coredumpctl info" gives me:
>
>> Stack trace of thread 143567:
>> #0  0x00007ff428f73590 n/a (n/a + 0x0)
>> #1  0x00007ff428f8af0f _dl_map_object_deps (/usr/lib64/ld-linux-x86-64.so.2 + 0x3f0f)
>> #2  0x00007ff428fa6970 dl_main (/usr/lib64/ld-linux-x86-64.so.2 + 0x1f970)
>> #3  0x00007ff428fa2c7c _dl_sysdep_start (/usr/lib64/ld-linux-x86-64.so.2 + 0x1bc7c)
>> #4  0x00007ff428fa4678 _dl_start_final (/usr/lib64/ld-linux-x86-64.so.2 + 0x1d678)
>> #5  0x00007ff428fa36a8 _start (/usr/lib64/ld-linux-x86-64.so.2 + 0x1c6a8)
>
> but inspecting in gdb using "coredumpctl debug" doesn't give me any sane
> backtrace.
>
> The .so is part of a Yocto build. If I copy the file out from its build
> directory to $HOME and run ldd on it, then there is no crash. So I
> suspect RUNPATH is involved somehow since it contains $ORIGIN.
>
> Any ideas of what I can do to investigate further ?

I suggest to run ld.so under GDB, with

  set startup-with-shell off
  set environment LD_TRACE_LOADED_OBJECTS 1
  b _start
  run ./mylib.so
  record btrace pt
  continue

And after the crash, look at

  record instruction-history

to see how it reached the crash.  This assumes that you have an
execution environment that supports branch tracing.

Thanks,
Florian


  reply	other threads:[~2022-02-04 13:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-04 13:45 Jacob Kroon
2022-02-04 13:58 ` Florian Weimer [this message]
2022-02-04 14:09   ` Jacob Kroon
2022-02-04 14:22     ` Florian Weimer
2022-02-04 14:27       ` Jacob Kroon
2022-02-04 16:09         ` Florian Weimer
2022-02-04 16:53           ` Jacob Kroon
2022-02-04 17:04             ` Florian Weimer
2022-02-04 17:11               ` Jacob Kroon
2022-02-04 17:15                 ` Florian Weimer
2022-02-07  8:36                   ` Jacob Kroon
2022-02-07 11:46                     ` Jacob Kroon
2022-02-07 11:55                       ` Florian Weimer
2022-02-07 12:15                         ` Jacob Kroon
2022-02-07 12:27                           ` Florian Weimer
2022-02-07 12:32                             ` Jacob Kroon
2022-02-07 13:39                               ` Jacob Kroon
2022-02-07 13:45                                 ` Jacob Kroon
2022-02-07 13:53                                   ` Adhemerval Zanella
2022-02-07 13:54                                     ` Jacob Kroon
2022-02-07 14:07                                 ` Florian Weimer
2022-02-07 16:28                                   ` Florian Weimer
2022-02-07 17:04                                     ` Jacob Kroon
2022-02-04 14:45       ` Jacob Kroon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735kypwcd.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).