From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29057 invoked by alias); 21 Dec 2013 11:02:27 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org Received: (qmail 29033 invoked by uid 48); 21 Dec 2013 11:02:25 -0000 From: "cole945 at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug gdb/16363] New: GDB crashes after canceling symbol completion Date: Sat, 21 Dec 2013 11:02:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cole945 at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-q4/txt/msg00593.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=16363 Bug ID: 16363 Summary: GDB crashes after canceling symbol completion Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: cole945 at gmail dot com GDB crashes after canceling symbol completion. The process of symbols/debug info loading are not exception-safe. The tested program must has a lot of debug information, so I can not give a simple program, but it's very easy to reproduce it by debugging cc1 (from gcc) or llc (from llvm) compiled with -g3 -O0. The steps to reproduce it 1. $ gdb /path/to/gcc/cc1 2. (gdb) break 3. Just wait 2 second and press ^C to cancel symbol completion 4. (gdb) break main 5. (gdb) run Starting program: /patth/to/gcc/cc1 Segmentation fault (core dumped) If it doesn't crash, just try this one more step 6. (gdb) call puts ("hello") Segmentation fault (core dumped) I've checked why it crashed. 1. When press for symbol completion, the symbols and dwarf are read (Some frames are omitted.) psymtab_to_symtab_1 -> process_full_comp_unit -> process_die -> allocate_symtab When allocate_symtab() is called, the symtab is inserted in current_program_space->objfiles->symtabs 2. Press ^C to cancel completion, set_quit_flags() is called 3. Depends on the timing, the QUIT macro in c_type_print_* will be call psymtab_to_symtab_1 -> process_full_comp_unit -> process_die -> allocate_symtab -> compute_delayed_physnames -> dwarf2_physname -> dwarf2_compute_name ... -> c_type_print_base -> QUIT When quit, the value of symtab->blockvector is leaving NULL. 4. symtab->blockvector should be set here psymtab_to_symtab_1 -> process_full_comp_unit -> process_die -> allocate_symtab -> compute_delayed_physnames -> dwarf2_physname -> dwarf2_compute_name ... -> c_type_print_base -> QUIT -> end_symtab_from_static_block -> symtab->blockvector = make_blockvector () 5. Crash in lookup_objfile_from_block, because BLOCKVECTOR (s) is NULL /* Go through SYMTABS. */ ALL_SYMTABS (obj, s) if (block == BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK)) <--- { if (obj->separate_debug_objfile_backlink) obj = obj->separate_debug_objfile_backlink; return obj; } 6. I think either QUIT in (ada|c|f|m2|p|)-typeprint.c should be removed, because we may in the middle of building symtabs, and it seems those function should not take a long time. Or if users cancel symbol completion, those symbol inserted in objfiles which blockvector are set yet should be removed, because they are not finishing their initialization (pst->readin is also not set yet when QUIT) -- You are receiving this mail because: You are on the CC list for the bug.