Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* linux-thread-db.c not only caller of add_thread, -> gdb segv
@ 2007-11-09  4:38 Douglas Evans
  2007-11-09 14:02 ` Daniel Jacobowitz
  0 siblings, 1 reply; 7+ messages in thread
From: Douglas Evans @ 2007-11-09  4:38 UTC (permalink / raw)
  To: gdb

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?


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-11-10 16:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-09  4:38 linux-thread-db.c not only caller of add_thread, -> gdb segv Douglas Evans
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox