From: "Douglas Evans" <dje@google.com>
To: gdb@sourceware.org
Subject: Re: linux-thread-db.c not only caller of add_thread, -> gdb segv
Date: Sat, 10 Nov 2007 01:27:00 -0000 [thread overview]
Message-ID: <e394668d0711091726l7551943eo3dd7fbfa551f4704@mail.gmail.com> (raw)
In-Reply-To: <20071109140225.GA32113@caradoc.them.org>
On Nov 9, 2007 6:02 AM, Daniel Jacobowitz <drow@false.org> wrote:
> This is true. But if you're using the Linux native target, and reach
> the point where any of the other add_thread calls are made, then
> there's already a bug. It is supposed to detect all new threads.
> It sort of has to - that's how infrun gets the new ptid_t.
Ah, thanks. I understand the threading support a bit better now.
[for completeness' sake, target = x86_64-linux]
> 3) Figure out how you got to any of the other add_thread calls.
Or that. :-)
I think I understand what's going on. Consider a threaded app that
first exec's itself
(e.g. because it wants to be run with a specific value for LD_LIBRARY_PATH,
the actual reason doesn't matter though).
GDB doesn't properly handle the fact that the original process is gone.
GDB detects the exec and removes thread_db_ops from the target stack.
But (a) it doesn't clear out thread_list and (b) still thinks it has control of
the running process.
By the time GDB gets to handle_inferior_event() case TARGET_WAITKIND_EXECD
it has added the new process to thread_list with the call
to add_thread in infrun.c, and thus there's an entry in thread_list with
"private" == NULL. thread_list also has stale entries at this point.
If the user does a ^c after the exec and then "info threads"
gdb will detect an internal error due to the stale entries in thread_list
and crash.
But if instead the user does a ^c and then "sharedlib some_library"
GDB will push thread_db_ops back on the target stack.
If the user then does "continue" thread_db_resume gets called and boom,
segv because thread->private == NULL in clear_lwpid_callback.
I'm working on a patch but I don't know this part of GDB very well.
[small test case available, I'll include it with the patch]
next prev parent reply other threads:[~2007-11-10 1:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-09 4:38 Douglas Evans
2007-11-09 14:02 ` Daniel Jacobowitz
2007-11-10 1:27 ` Douglas Evans [this message]
2007-11-10 3:26 ` Daniel Jacobowitz
2007-11-10 3:40 ` Douglas Evans
2007-11-10 5:20 ` Douglas Evans
2007-11-10 16:00 ` Daniel Jacobowitz
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=e394668d0711091726l7551943eo3dd7fbfa551f4704@mail.gmail.com \
--to=dje@google.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