c++/2160: gdb segfaults on extern "C"

neeman@webone.com.au neeman@webone.com.au
Sat Aug 26 09:28:00 GMT 2006

>Number:         2160
>Category:       c++
>Synopsis:       gdb segfaults on extern "C"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 26 09:28:01 UTC 2006
>Originator:     neeman@webone.com.au
>Release:        6.5
uname -a:
Linux joe 2.6.15-gentoo-r5 #1 SMP Thu Mar 2 16:48:51 EST 2006 x86_64 AMD Opteron(tm) Processor 242 GNU/Linux

GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".
GDB segfaults every time I try to call a function (from within a C++ program) that has been defined extern "C". A minimal example:

/* file test.c */
extern "C" {
    int foo ()
        return 7;

int main ()
    return foo ();
/* end test.c */

I compile with g++ -g test.c
I run "gdb a.out"
I set "breakpoint main"
I type "run"
When GDB hits the breakpoint, I do "print foo()"
GDB crashes.

Here is a backtrace of GDB. If debugging info is necessary, let me know and I can recompile GDB.

Program received signal SIGSEGV, Segmentation fault.
0x00002aaaaafe31f0 in strlen () from /lib/tls/libc.so.6
(gdb) bt
#0  0x00002aaaaafe31f0 in strlen () from /lib/tls/libc.so.6
#1  0x000000000055de51 in cp_demangled_name_to_comp ()
#2  0x0000000000551873 in cp_func_name ()
#3  0x00000000004ab55c in find_overload_match ()
#4  0x00000000004a7525 in evaluate_subexp_standard ()
#5  0x00000000004a453d in evaluate_expression ()
#6  0x00000000004b459d in output_command ()
#7  0x000000000044644d in execute_command ()
#8  0x00000000004d8627 in push_prompt ()
#9  0x00000000004d92c8 in display_gdb_prompt ()
#10 0x000000000057be0a in rl_callback_read_char ()
#11 0x00000000004d87d9 in push_prompt ()
#12 0x00000000004d750f in delete_async_signal_handler ()
#13 0x00000000004d7d46 in gdb_do_one_event ()
#14 0x00000000004d4c6b in catch_errors ()
#15 0x0000000000483286 in _initialize_tui_interp ()
#16 0x000000000043fe89 in gdb_main ()
#17 0x00000000004d4c6b in catch_errors ()
#18 0x0000000000440546 in gdb_main ()
#19 0x00000000004d4c6b in catch_errors ()
#20 0x000000000043fe74 in gdb_main ()
#21 0x000000000043fe46 in main ()



More information about the Gdb-prs mailing list