public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cole945 at gmail dot com" <sourceware-bugzilla@sourceware.org>
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	[thread overview]
Message-ID: <bug-16363-4717@http.sourceware.org/bugzilla/> (raw)

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


                 reply	other threads:[~2013-12-21 11:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-16363-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).