From: "Douglas Evans" <dje@google.com>
To: gdb@sourceware.org
Subject: linux-thread-db.c not only caller of add_thread, -> gdb segv
Date: Fri, 09 Nov 2007 04:38:00 -0000 [thread overview]
Message-ID: <e394668d0711082038r412087eaj3b0cda56cdddaff0@mail.gmail.com> (raw)
Hi. I'm trying to decide what's the best way to fix a bug I've found.
linux-thread-db.c is not the only caller of add_thread, e.g. infrun.c
calls it too.
linux-thread-db.c assumes thread_info.private is non-NULL, e.g. here:
static int
clear_lwpid_callback (struct thread_info *thread, void *dummy)
{
/* If we know that our thread implementation is 1-to-1, we could
save
a certain amount of information; it's not clear how much, so we
are always conservative. */
thread->private->th_valid = 0;
thread->private->ti_valid = 0;
return 0;
}
called from here:
#0 0x00000000004681a4 in clear_lwpid_callback (thread=0xb132d0,
dummy=0x0) at ../../src/gdb/linux-thread-db.c:765
#1 0x00000000004f8480 in iterate_over_threads (callback=0x46818d
<clear_lwpid_callback>, data=0x0) at ../../src/gdb/thread.c:204
#2 0x00000000004682a6 in thread_db_resume (ptid={pid = -1, lwp = 0,
tid = 0}, step=0, signo=TARGET_SIGNAL_0) at
../../src/gdb/linux-thread-db.c:782
#3 0x00000000004eb83d in resume (step=0, sig=TARGET_SIGNAL_0) at
../../src/gdb/infrun.c:614
#4 0x00000000004ebc14 in proceed (addr=18446744073709551615,
siggnal=TARGET_SIGNAL_DEFAULT, step=0) at ../../src/gdb/infrun.c:805
This is iterating over all threads, some of which were created via
add_thread calls outside of linux-thread-db.c, and thus
thread_info.private is NULL and boom, segv.
I can see two solutions
1) ensure all calls to add_thread properly initialize thread_info.private
(via callback or whatever)
2) have linux-thread-db.c always check thread_info.private before
dereferencing it.
Comments?
next reply other threads:[~2007-11-09 4:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-09 4:38 Douglas Evans [this message]
2007-11-09 14:02 ` Daniel Jacobowitz
2007-11-10 1:27 ` Douglas Evans
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=e394668d0711082038r412087eaj3b0cda56cdddaff0@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