From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 868 invoked by alias); 12 Jul 2011 11:15:08 -0000 Received: (qmail 858 invoked by uid 22791); 12 Jul 2011 11:15:06 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_GD,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Jul 2011 11:14:46 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6CBEj1V007101 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 12 Jul 2011 07:14:45 -0400 Received: from host1.jankratochvil.net ([10.3.113.13]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p6CBEhni029506 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 12 Jul 2011 07:14:45 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p6CBEggw023424; Tue, 12 Jul 2011 13:14:42 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p6CBEfuX023423; Tue, 12 Jul 2011 13:14:41 +0200 Date: Tue, 12 Jul 2011 15:59:00 -0000 From: Jan Kratochvil To: Sterling Augustine Cc: gdb-patches@sourceware.org Subject: [dwarf2_mark_helper patch] Re: [PATCH] Make interrupting tab-completion safe. Message-ID: <20110712111440.GA21949@host1.jankratochvil.net> References: <20110612121158.GA10611@host1.jankratochvil.net> <20110711185334.GA10138@host1.jankratochvil.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="W/nzBZO5zC0uMSeA" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-07/txt/msg00301.txt.bz2 --W/nzBZO5zC0uMSeA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2391 On Mon, 11 Jul 2011 23:36:24 +0200, Sterling Augustine wrote: > On head, synced this morning, I still get the failure. OK, this is a different kind of crash than I reproduced before. Re-posting back to the list with the off-list mail attached (+reformatted). It is reproducible only for: * either cross-CU DIE reference by its offset but that is never produced by GCC so I do not consider it here. * or .debug_types, therefore -gdwarf-4 possibly with -fdebug-types-section. And then also it must have: * missing DW_AT_MIPS_linkage_name which I guess only Google is using. One can simulate it in gdb by -ex 'set debug check-physname'. Otherwise C++ parameters printing would not get called. And for the artificial reproducibility: * The referenced CUs must contain C++ parameters. To make possibly CTRL-C application while reading them in. * The referencing CU should not contain C++ parameters. Otherwise CTRL-C could apply too early. Recommending some `ulimit -v 2000000' otherwise GDB can eat out the memory. perl -le '$n=1000;print "class C$_ { public: void m (C$_ *c) {} } c$_;" for 1..$n;print "int main () { ";print "c$_.m (&c$_);" for 1..$n;print "}";'|g++ -gdwarf-4 -fdebug-types-section -Wall -x c++ -;./gdb -nx -ex 'set debug check-physname' ./a.out g++ (GCC) 4.7.0 20110712 (experimental) GNU gdb (GDB) 7.3.50.20110711-cvs (gdb) b ^CQuit (gdb) b by: (gdb) b (gdb) b One can also use $n=10000 to have more than 1sec for . > The segmentation fault happens because per_cu->cu == NULL. While the fix is doing just the straightforward thing I do not see what better fix could be made. Thanks, Jan gdb/ 2011-07-12 Jan Kratochvil Fix occasional crash of CTRL-C during DWARF read in. * dwarf2read.c (dwarf2_mark_helper): Return on NULL CU. --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -15455,6 +15455,13 @@ dwarf2_mark_helper (void **slot, void *data) struct dwarf2_per_cu_data *per_cu; per_cu = (struct dwarf2_per_cu_data *) *slot; + + /* cu->dependencies references may not yet have been ever read if QUIT aborts + reading of the chain. As such dependencies remain valid there is not much + useful to track and undo them during QUIT cleanups. */ + if (per_cu->cu == NULL) + return 1; + if (per_cu->cu->mark) return 1; per_cu->cu->mark = 1; --W/nzBZO5zC0uMSeA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename=cu-trace Content-length: 11462 On Mon, Jul 11, 2011 at 11:53 AM, Jan Kratochvil wrote: > If you still have it reproducible with FSF GDB HEAD or 7.3 snapshots please > provide some backtrace etc. On head, synced this morning, I still get the failure. Two stack traces are below. The first is a trace from the actual successful quit call. The second is the actual crash. After each "b" on the command line, I type , which of course doesn't show up in the log. The segmentation fault happens because per_cu->cu == NULL. Sterling ******* Starting program: /usr/local/google/users/saugustine/gdb-tot/build/gdb/gdb really_big_program [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/libthread_db.so.1". GNU gdb (GDB) 7.3.50.20110711-cvs Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-unknown-linux-gnu". For bug reporting instructions, please see: ... Reading symbols from really_big_program...done. warning: Missing auto-load scripts referenced in section .debug_gdb_scripts of file really_big_program Use `info auto-load-scripts [REGEXP]' to list them. (gdb) b Program received signal SIGINT, Interrupt. ^C Program received signal SIGINT, Interrupt. Breakpoint 1, quit () at /home/saugustine/tot-gdb/src/gdb/utils.c:1192 1192 { (top) where #0 quit () at /home/saugustine/tot-gdb/src/gdb/utils.c:1192 #1 0x00000000005f890f in c_type_print_base (type=0x1bcb0290, stream=0x19ff6d00, show=-1, level=0) at /home/saugustine/tot-gdb/src/gdb/c-typeprint.c:730 #2 0x00000000005fa5f9 in c_print_type (type=0x1bcb0290, varstring=0x70622b "", stream=0x19ff6d00, show=-1, level=0) at /home/saugustine/tot-gdb/src/gdb/c-typeprint.c:63 #3 0x00000000005fa7c6 in c_type_print_args (type=0x1bd8f610, stream=0x19ff6d00, linkage_name=, language=language_cplus) at /home/saugustine/tot-gdb/src/gdb/c-typeprint.c:439 #4 0x00000000005b1fc2 in dwarf2_compute_name (name=, die=0x1bc9d8c0, cu=0x169a83e0, physname=1) at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:5121 #5 0x00000000005b23dc in dwarf2_physname (name=0x7fffdcd38bfe "scoped_ptr", die=0x1bc9d8c0, cu=0x169a83e0) at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:5241 #6 0x00000000005b6276 in compute_delayed_physnames (cu=) at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:4651 #7 process_full_comp_unit (per_cu=) at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:4729 #8 process_queue (objfile=) at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:4445 #9 dw2_do_instantiate_symtab (objfile=, per_cu=) at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:1812 #10 0x00000000005b6f73 in dwarf2_psymtab_to_symtab (pst=0x15c475a0) at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:4402 #11 0x0000000000543954 in psymtab_to_symtab (pst=0x15c475a0) at /home/saugustine/tot-gdb/src/gdb/psymtab.c:752 #12 0x00000000005448dd in expand_symtabs_matching_via_partial (objfile=0xc68ed0, file_matcher=0, name_matcher=, kind=ALL_DOMAIN, data=) at /home/saugustine/tot-gdb/src/gdb/psymtab.c:1271 #13 0x0000000000543573 in expand_partial_symbol_names (fun=0x53cbe0 , data=0x7fffffffd8e0) at /home/saugustine/tot-gdb/src/gdb/psymtab.c:1913 #14 0x0000000000540385 in default_make_symbol_completion_list_break_on (text=0x7fffffffd9c2 "", word=0x7fffffffd9c2 "", break_on=0x70622b "") at /home/saugustine/tot-gdb/src/gdb/symtab.c:3897 #15 0x0000000000574059 in location_completer (ignore=, text=0x7fffffffd9c2 "", word=0x7fffffffd9c2 "") at /home/saugustine/tot-gdb/src/gdb/completer.c:286 #16 0x0000000000573623 in complete_line_internal (text=, line_buffer=, point=, reason=handle_completions) at /home/saugustine/tot-gdb/src/gdb/completer.c:791 #17 0x0000000000573afc in line_completion_function (point=, line_buffer=, matches=, text=) at /home/saugustine/tot-gdb/src/gdb/completer.c:885 #18 readline_line_completion_function (text=0x364b130 "", matches=) at /home/saugustine/tot-gdb/src/gdb/completer.c:102 #19 0x000000000063d673 in rl_completion_matches (text=0x364b130 "", entry_function=) at /home/saugustine/tot-gdb/src/readline/complete.c:1997 #20 0x000000000063ec5b in rl_complete_internal (what_to_do=9) at /home/saugustine/tot-gdb/src/readline/complete.c:1835 #21 0x00000000006366db in _rl_dispatch_subseq (key=9, map=0xab0400, got_subseq=0) at /home/saugustine/tot-gdb/src/readline/readline.c:774 #22 0x0000000000636eb7 in readline_internal_char () at /home/saugustine/tot-gdb/src/readline/readline.c:552 #23 0x000000000064b145 in rl_callback_read_char () at /home/saugustine/tot-gdb/src/readline/callback.c:201 #24 0x0000000000571f89 in rl_callback_read_char_wrapper (client_data=0x1bcb0290) at /home/saugustine/tot-gdb/src/gdb/event-top.c:177 #25 0x0000000000570818 in process_event () at /home/saugustine/tot-gdb/src/gdb/event-loop.c:402 #26 0x0000000000571c1a in gdb_do_one_event (data=) at /home/saugustine/tot-gdb/src/gdb/event-loop.c:467 #27 0x000000000056b9db in catch_errors (func=, func_args=, errstring=, mask=) at /home/saugustine/tot-gdb/src/gdb/exceptions.c:506 #28 0x00000000004df7d0 in tui_command_loop (data=) at /home/saugustine/tot-gdb/src/gdb/tui/tui-interp.c:172 #29 0x0000000000458069 in captured_command_loop (data=0x1bcb0290) at /home/saugustine/tot-gdb/src/gdb/main.c:230 #30 0x000000000056b9db in catch_errors (func=, func_args=, errstring=, mask=) at /home/saugustine/tot-gdb/src/gdb/exceptions.c:506 #31 0x0000000000458ca6 in captured_main (data=) at /home/saugustine/tot-gdb/src/gdb/main.c:937 #32 0x000000000056b9db in catch_errors (func=, func_args=, errstring=, mask=) at /home/saugustine/tot-gdb/src/gdb/exceptions.c:506 #33 0x0000000000458054 in gdb_main (args=0x19ff6d00) at /home/saugustine/tot-gdb/src/gdb/main.c:946 #34 0x000000000045801e in main (argc=, argv=0x19ff6d00) at /home/saugustine/tot-gdb/src/gdb/gdb.c:35 (top) c Continuing. Quit (gdb) b Program received signal SIGSEGV, Segmentation fault. 0x00000000005a757b in dwarf2_mark_helper (slot=0x1bae5e20, data=0x0) at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:15462 15462 if (per_cu->cu->mark) (top) where #0 0x00000000005a757b in dwarf2_mark_helper (slot=0x1bae5e20, data=0x0) at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:15462 #1 0x00000000006e36f8 in htab_traverse_noresize (htab=, callback=0x5a7570 , info=0x0) at /home/saugustine/tot-gdb/src/libiberty/hashtab.c:784 #2 0x00000000005a75a8 in dwarf2_mark_helper (slot=, data=) at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:15467 #3 0x00000000006e36f8 in htab_traverse_noresize (htab=, callback=0x5a7570 , info=0x0) at /home/saugustine/tot-gdb/src/libiberty/hashtab.c:784 #4 0x00000000005a74a8 in dwarf2_mark (cu=) at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:15482 #5 age_cached_comp_units () at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:15228 #6 0x00000000005b6408 in dw2_do_instantiate_symtab (objfile=0x0, per_cu=0x9b6a780) at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:1816 #7 0x00000000005b6f73 in dwarf2_psymtab_to_symtab (pst=0x15c46a50) at /home/saugustine/tot-gdb/src/gdb/dwarf2read.c:4402 #8 0x0000000000543954 in psymtab_to_symtab (pst=0x15c46a50) at /home/saugustine/tot-gdb/src/gdb/psymtab.c:752 #9 0x00000000005448dd in expand_symtabs_matching_via_partial (objfile=0xc68ed0, file_matcher=0, name_matcher=, kind=ALL_DOMAIN, data=) at /home/saugustine/tot-gdb/src/gdb/psymtab.c:1271 #10 0x0000000000543573 in expand_partial_symbol_names (fun=0x53cbe0 , data=0x7fffffffd8e0) at /home/saugustine/tot-gdb/src/gdb/psymtab.c:1913 #11 0x0000000000540385 in default_make_symbol_completion_list_break_on (text=0x7fffffffd9c2 "", word=0x7fffffffd9c2 "", break_on=0x70622b "") at /home/saugustine/tot-gdb/src/gdb/symtab.c:3897 #12 0x0000000000574059 in location_completer (ignore=, text=0x7fffffffd9c2 "", word=0x7fffffffd9c2 "") at /home/saugustine/tot-gdb/src/gdb/completer.c:286 #13 0x0000000000573623 in complete_line_internal (text=, line_buffer=, point=, reason=handle_completions) at /home/saugustine/tot-gdb/src/gdb/completer.c:791 #14 0x0000000000573afc in line_completion_function (point=, line_buffer=, matches=, text=) at /home/saugustine/tot-gdb/src/gdb/completer.c:885 #15 readline_line_completion_function (text=0xe5675f0 "", matches=) at /home/saugustine/tot-gdb/src/gdb/completer.c:102 #16 0x000000000063d673 in rl_completion_matches (text=0xe5675f0 "", entry_function=) at /home/saugustine/tot-gdb/src/readline/complete.c:1997 #17 0x000000000063ec5b in rl_complete_internal (what_to_do=9) at /home/saugustine/tot-gdb/src/readline/complete.c:1835 #18 0x00000000006366db in _rl_dispatch_subseq (key=9, map=0xab0400, got_subseq=0) at /home/saugustine/tot-gdb/src/readline/readline.c:774 #19 0x0000000000636eb7 in readline_internal_char () at /home/saugustine/tot-gdb/src/readline/readline.c:552 #20 0x000000000064b145 in rl_callback_read_char () at /home/saugustine/tot-gdb/src/readline/callback.c:201 #21 0x0000000000571f89 in rl_callback_read_char_wrapper (client_data=0x1bae5e20) at /home/saugustine/tot-gdb/src/gdb/event-top.c:177 #22 0x0000000000570818 in process_event () at /home/saugustine/tot-gdb/src/gdb/event-loop.c:402 #23 0x0000000000571c1a in gdb_do_one_event (data=) at /home/saugustine/tot-gdb/src/gdb/event-loop.c:467 #24 0x000000000056b9db in catch_errors (func=, func_args=, errstring=, mask=) at /home/saugustine/tot-gdb/src/gdb/exceptions.c:506 #25 0x00000000004df7d0 in tui_command_loop (data=) at /home/saugustine/tot-gdb/src/gdb/tui/tui-interp.c:172 #26 0x0000000000458069 in captured_command_loop (data=0x1bae5e20) at /home/saugustine/tot-gdb/src/gdb/main.c:230 #27 0x000000000056b9db in catch_errors (func=, func_args=, errstring=, mask=) at /home/saugustine/tot-gdb/src/gdb/exceptions.c:506 #28 0x0000000000458ca6 in captured_main (data=) at /home/saugustine/tot-gdb/src/gdb/main.c:937 #29 0x000000000056b9db in catch_errors (func=, func_args=, errstring=, mask=) at /home/saugustine/tot-gdb/src/gdb/exceptions.c:506 #30 0x0000000000458054 in gdb_main (args=0x0) at /home/saugustine/tot-gdb/src/gdb/main.c:946 #31 0x000000000045801e in main (argc=, argv=0x0) at /home/saugustine/tot-gdb/src/gdb/gdb.c:35 (top) --W/nzBZO5zC0uMSeA--