Package: gdb
Version: 6.4.90-debian

The patches that debian-etch adds to gdb-6.4.90 make it SEGV if
thread_db.so doesn't contain all of the expected symbols (td_init,
td_ta_new, td_ta_map_id2thr, td_ta_map_lwp2thr etc).

Using a debug build of gdb-6.4.90-debian (built with `apt-get -b
source gdb') gives a core dump with the following backtrace:

    #0  0x08093765 in check_for_thread_db () at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/linux-thread-db.c:676
    676           printf_unfiltered (_("Using host libthread_db library 
\"%s\".\n"),
    (gdb) bt
    #0  0x08093765 in check_for_thread_db () at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/linux-thread-db.c:676
    #1  0x081a327b in inf_ptrace_him (pid=2684) at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/inf-ptrace.c:126
    #2  0x081a3af9 in fork_inferior (
        exec_file_arg=0x82fe030 ..., allargs=0x8334c68 "", env=0x82df708, 
traceme_fun=0x81a2920 <inf_ptrace_me>, init_trace_fun=0x81a3220 
<inf_ptrace_him>, pre_trace_fun=0, 
        shell_file_arg=0x0) at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/fork-child.c:396
    #3  0x081a321d in inf_ptrace_create_inferior (
        exec_file=0x82fe030 "...", allargs=0x8334c68 "", env=0x82df708, 
from_tty=1) at /home/gregjules/gdb-6.4.90.dfsg/gdb/inf-ptrace.c:138
    #4  0x0810c3ff in run_command_1 (args=0x0, from_tty=1, 
tbreak_at_main=<value optimized out>) at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/infcmd.c:546
    #5  0x0807f133 in execute_command (p=0x82be245 "", from_tty=1) at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/top.c:452
    #6  0x0811ca1b in command_handler (command=0x82be240 "") at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/event-top.c:512
    #7  0x0811d759 in command_line_handler (rl=0x830e858 "") at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/event-top.c:797
    #8  0xb7f421a0 in rl_callback_read_char () from /lib/libreadline.so.5
    #9  0x0811cbdb in rl_callback_read_char_wrapper (client_data=0x0) at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/event-top.c:178
    #10 0x0811c552 in handle_file_event (event_file_desc=0) at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/event-loop.c:730
    #11 0x0811b9fd in process_event () at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/event-loop.c:343
    #12 0x0811c1c5 in gdb_do_one_event (data=0x0) at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/event-loop.c:380
    #13 0x08118f3b in catch_errors (func=0x811c0b0 <gdb_do_one_event>, 
func_args=0x0, errstring=0x8227c00 "", mask=6)
        at /home/gregjules/gdb-6.4.90.dfsg/gdb/exceptions.c:515
    #14 0x080c19d4 in tui_command_loop (data=0x0) at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/tui/tui-interp.c:151
    #15 0x0811956f in current_interp_command_loop () at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/interps.c:278
    #16 0x0807825b in captured_command_loop (data=0x0) at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/main.c:101
    #17 0x08118f3b in catch_errors (func=0x8078250 <captured_command_loop>, 
func_args=0x0, errstring=0x8227c00 "", mask=6)
        at /home/gregjules/gdb-6.4.90.dfsg/gdb/exceptions.c:515
    #18 0x08078a64 in captured_main (data=0xbf8cf4a4) at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/main.c:834
    #19 0x08118f3b in catch_errors (func=0x8078290 <captured_main>, 
func_args=0xbf8cf4a4, errstring=0x8227c00 "", mask=6)
        at /home/gregjules/gdb-6.4.90.dfsg/gdb/exceptions.c:515
    #20 0x08078243 in gdb_main (args=0xbf8cf4a4) at 
/home/gregjules/gdb-6.4.90.dfsg/gdb/main.c:843
    #21 0x08078205 in main (argc=Cannot access memory at address 0x0
    ) at /home/gregjules/gdb-6.4.90.dfsg/gdb/gdb.c:35
    (gdb) p all_pointers
    $1 = (struct thread_db_pointers *) 0x0
    (gdb) p using_thread_db
    $2 = 0
    (gdb) 

The SEGV occurs in linux-thread-db.c:check_for_thread_db():

    void
    check_for_thread_db (void)
    {
      static int already_loaded;

      /* First time through, report that libthread_db was successfuly
         loaded.  Can't print this in in thread_db_load as, at that stage,
         the interpreter and it's console haven't started.  */

      if (!already_loaded)
        {
          printf_unfiltered (_("Using host libthread_db library \"%s\".\n"),
                             all_pointers->filename);
          already_loaded = 1;
        }
      ...

When <already_loaded> is 0, the above call to printf_unfiltered()
dereferences <all_pointers>, but <all_pointers> can be NULL if, earlier
on, thread_db_load() returned 0 due to verbose_dlsym() returning NULL
for one of the expected thread_db functions.

The segv doesn't occur with gdb-6.4.90 without the debian patches.

The obvious fix makes things work ok:

    void
    check_for_thread_db (void)
    {
      static int already_loaded;

      /* First time through, report that libthread_db was successfuly
         loaded.  Can't print this in in thread_db_load as, at that stage,
         the interpreter and it's console haven't started.  */

      if (!already_loaded)
        {
          if (all_pointers)
            printf_unfiltered (_("Using host libthread_db library \"%s\".\n"),
                             all_pointers->filename);
          already_loaded = 1;
        }
      ...

Here are some details of my system:

    uname -a:
        Linux pc1-debian-etch 2.6.18-3-k7 #1 SMP Mon Dec 4 17:23:11 UTC 2006 
i686 GNU/Linux
    ls -l /lib/libc.so.6:
        lrwxrwxrwx 1 root root 13 2007-01-23 16:48 /lib/libc.so.6 -> 
libc-2.3.6.so

I hope that all makes sense.
    
- Julian

-- 
http://op59.net/



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to