public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Segfault doing 'info tracepoints'
@ 2010-08-26 15:14 Marc Khouzam
  0 siblings, 0 replies; only message in thread
From: Marc Khouzam @ 2010-08-26 15:14 UTC (permalink / raw)
  To: 'gdb@sourceware.org'

Hi,

I get a segfault doing 'info tracepoints' during trace visualization (tfind)
and using a dynamically linked library that I built.  GDB 7.2 of course.

Maybe not the most common usecase, but since it crashed GDB, I thought I'd
mention it.  The crash is in minsyms.c:lookup_minimal_symbol_by_pc_section_1()
which is too deep for my knowledge.

The back trace is below, followed by the session to trigger it, followed
by the application and dyn lib I used.  Please note that my environment is
pretty old with a GCC 4.1.2.

In case anyone has the time, here goes.

Thanks

Marc


Backtrace:
---------
Program received signal SIGSEGV, Segmentation fault.
0x08097fcc in lookup_minimal_symbol_by_pc_section_1 (pc=3085948047, section=0x864c40c, want_trampoline=<value optimized out>) at ../../src/gdb/minsyms.c:520
520               if (pc >= SYMBOL_VALUE_ADDRESS (&msymbol[lo]))
(gdb) bt
#0  0x08097fcc in lookup_minimal_symbol_by_pc_section_1 (pc=3085948047, section=0x864c40c, want_trampoline=<value optimized out>) at ../../src/gdb/minsyms.c:520
#1  0x08168afb in find_pc_sect_symtab (pc=3085948047, section=0x864c40c) at ../../src/gdb/symtab.c:1700
#2  0x081666ff in blockvector_for_pc_sect (pc=3085948047, section=0x864c40c, pblock=0xbfffbee4, symtab=0x0) at ../../src/gdb/block.c:106
#3  0x08166737 in block_for_pc_sect (pc=3085948047, section=0x864c40c) at ../../src/gdb/block.c:182
#4  0x0812f388 in find_pc_sect_function (pc=3085948047, section=0x864c40c) at ../../src/gdb/blockframe.c:139
#5  0x081336b8 in print_breakpoint_location (b=0x85c97c0, loc=0x85d0600, loc_number=<value optimized out>, last_loc=0xbfffc0b8, print_address_bits=32, allflag=0)
    at ../../src/gdb/breakpoint.c:4401
#6  print_one_breakpoint_location (b=0x85c97c0, loc=0x85d0600, loc_number=<value optimized out>, last_loc=0xbfffc0b8, print_address_bits=32, allflag=0)
    at ../../src/gdb/breakpoint.c:4624
#7  0x08133830 in print_one_breakpoint (b=0x85c97c0, last_loc=0xbfffc0b8, print_address_bits=32, allflag=0) at ../../src/gdb/breakpoint.c:4788
#8  0x08133b97 in breakpoint_1 (bnum=-1, allflag=0, filter=0x812f960 <is_tracepoint>) at ../../src/gdb/breakpoint.c:4986
#9  0x08133dbb in tracepoints_info (tpnum_exp=0x0, from_tty=1) at ../../src/gdb/breakpoint.c:11029
#10 0x0809bb82 in execute_command (p=0x84e8fbf "", from_tty=1) at ../../src/gdb/top.c:422
#11 0x081985d7 in command_handler (command=0x84e8fb8 "info tr") at ../../src/gdb/event-top.c:498
#12 0x0819916c in command_line_handler (rl=0x8626de8 "\210\234\\\b\370mb\b") at ../../src/gdb/event-top.c:702
#13 0x0826ab04 in rl_callback_read_char () at ../../src/readline/callback.c:205
#14 0x0819864b in rl_callback_read_char_wrapper (client_data=0x0) at ../../src/gdb/event-top.c:178
#15 0x0819824e in handle_file_event (data=...) at ../../src/gdb/event-loop.c:817
#16 0x08197595 in process_event () at ../../src/gdb/event-loop.c:399
#17 0x0819818b in gdb_do_one_event (data=0x0) at ../../src/gdb/event-loop.c:464
#18 0x08192a63 in catch_errors (func=0x8197f90 <gdb_do_one_event>, func_args=0x0, errstring=0x83a311e "", mask=6) at ../../src/gdb/exceptions.c:518
#19 0x081127f4 in tui_command_loop (data=0x0) at ../../src/gdb/tui/tui-interp.c:171
#20 0x0819325f in current_interp_command_loop () at ../../src/gdb/interps.c:291
#21 0x0809202b in captured_command_loop (data=0x0) at ../../src/gdb/main.c:227
#22 0x08192a63 in catch_errors (func=0x8092020 <captured_command_loop>, func_args=0x0, errstring=0x83a311e "", mask=6) at ../../src/gdb/exceptions.c:518
#23 0x080927e4 in captured_main (data=0xbfffc3e4) at ../../src/gdb/main.c:910
#24 0x08192a63 in catch_errors (func=0x8092060 <captured_main>, func_args=0xbfffc3e4, errstring=0x83a311e "", mask=6) at ../../src/gdb/exceptions.c:518
#25 0x08091df1 in gdb_main (args=0xbfffc3e4) at ../../src/gdb/main.c:919
#26 0x08091db5 in main (argc=0, argv=0x1d00800) at ../../src/gdb/gdb.c:34


Session (gdb inside gdb):
-------

> gdb.7.2 gdb.7.2
GNU gdb (GDB) 7.1.90.20100805-cvs
Reading symbols from /local/lmckhou/bin/gdb.7.2...done.
(gdb) run
Starting program: /local/lmckhou/bin/gdb.7.2 
[Thread debugging using libthread_db enabled]
GNU gdb (GDB) 7.1.90.20100805-cvs
(gdb) file a.out
Reading symbols from /local/lmckhou/testing/a.out...done.
(gdb) target remote localhost:9999
Remote debugging using localhost:9999
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
0xb7f00840 in _start () from /lib/ld-linux.so.2
Created trace state variable $trace_timestamp for target's variable 1.
(gdb) b 21
Breakpoint 1 at 0x80485e7: file myapp.c, line 21.
(gdb) c
Continuing.

Breakpoint 1, main () at myapp.c:21
21           *(void **) (&foo) = dlsym(handle, "foo");
(gdb) tr mydll.c:2
Tracepoint 2 at 0xb7efd48f: file mydll.c, line 2.
(gdb) tstart
(gdb) b 31
Breakpoint 3 at 0x8048662: file myapp.c, line 31.
(gdb) c
Continuing.

Breakpoint 3, main () at myapp.c:31
31           exit(EXIT_SUCCESS);
(gdb) tstop
(gdb) info tr
Num     Type           Disp Enb Address    What
2       tracepoint     keep y   0xb7efd48f mydll.c:2
(gdb) tfind 0
Found trace frame 0, tracepoint 2
#0  0xb7efd48f in ?? ()
(gdb)tdump
Data collected at tracepoint 2, trace frame 0:
(gdb) info tr
Num     Type           Disp Enb Address    What

Program received signal SIGSEGV, Segmentation fault.
0x08097fcc in lookup_minimal_symbol_by_pc_section_1 (pc=3085948047, section=0x864c40c, want_trampoline=<value optimized out>) at ../../src/gdb/minsyms.c:520
520               if (pc >= SYMBOL_VALUE_ADDRESS (&msymbol[lo]))
(gdb) bt

Test app and dll:
> cat mydll.c
int foo() {
        return 1234;
}

> cat myapp.c 
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dlfcn.h>

void typedef (*foo_func)();

int main(void) {

     int (*foo)(void);
     char *error;
     int i = 0;

     void* handle = dlopen("./mydll.so", RTLD_LAZY);
     if (!handle) {
         printf("could not open dll\n");
         exit(EXIT_FAILURE);
     }
     dlerror();    /* Clear any existing error */

     *(void **) (&foo) = dlsym(handle, "foo");

     if ((error = dlerror()) != NULL) {
         printf("could not call dll\n");
         fprintf(stderr, "%s\n", error);
         exit(EXIT_FAILURE);
     }

     printf("%d\n", (*foo)());
     dlclose(handle);
     exit(EXIT_SUCCESS);
}

Built with:
> gcc -g -c -fpic mydll.c && gcc -g -shared -o mydll.so mydll.o && gcc -g -ldl myapp.c

> gcc --version
gcc (GCC) 4.1.2 20070115 (SUSE Linux)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-08-26 15:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-26 15:14 Segfault doing 'info tracepoints' Marc Khouzam

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).