public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/27541] gdb crashes on "file -readnow"
Date: Tue, 30 Mar 2021 17:37:32 +0000	[thread overview]
Message-ID: <bug-27541-4717-fArILsZOeY@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-27541-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=27541

--- Comment #9 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Marchi <simark@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8a91fbdf3b570460afdf0cac0d7f087b9d55f60c

commit 8a91fbdf3b570460afdf0cac0d7f087b9d55f60c
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Tue Mar 30 13:37:11 2021 -0400

    gdb/dwarf: disable per-BFD resource sharing for -readnow objfiles

    New in v2:

      - Disable sharing only for -readnow objfiles, not all objfiles.

    As described in PR 27541, we hit an internal error when loading a binary
    the standard way and then loading it with the -readnow option:

        $ ./gdb -nx -q --data-directory=data-directory ~/a.out -ex "set confirm
off" -ex "file -readnow ~/a.out"
        Reading symbols from /home/simark/a.out...
        Reading symbols from ~/a.out...
        /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8098: internal-error:
void create_all_comp_units(dwarf2_per_objfile*): Assertion
`per_objfile->per_bfd->all_comp_units.empty ()' failed.

    This is a recurring problem that exposes a design issue in the DWARF
    per-BFD sharing feature.  Things work well when loading a binary with
    the same method (with/without index, with/without readnow) twice in a
    row.  But they don't work so well when loading a binary with different
    methods.  See this previous fix, for example:

        efb763a5ea35 ("gdb: check for partial symtab presence in
dwarf2_initialize_objfile")

    That one handled the case where the first load is normal (uses partial
    symbols) and the second load uses an index.

    The problem is that when loading an objfile with a method A, we create a
    dwarf2_per_bfd and some dwarf2_per_cu_data and initialize them with the
    data belonging to that method.  When loading another obfile sharing the
    same BFD but with a different method B, it's not clear how to re-use the
    dwarf2_per_bfd/dwarf2_per_cu_data previously created, because they
    contain the data specific to method A.

    I think the most sensible fix would be to not share a dwarf2_per_bfd
    between two objfiles loaded with different methods.  That means that two
    objfiles sharing the same BFD and loaded the same way would share a
    dwarf2_per_bfd.  Two objfiles sharing the same BFD but loaded with
    different methods would use two different dwarf2_per_bfd structures.

    However, this isn't a trivial change.  So to fix the known issue quickly
    (including in the gdb 10 branch), this patch just disables all
    dwarf2_per_bfd sharing for objfiles using READNOW.

    Generalize the gdb.base/index-cache-load-twice.exp test to test all
    the possible combinations of loading a file with partial symtabs, index
    and readnow.  Move it to gdb.dwarf2, since it really exercises features
    of the DWARF reader.

    gdb/ChangeLog:

            PR gdb/27541
            * dwarf2/read.c (dwarf2_has_info): Don't share dwarf2_per_bfd
            with objfiles using READNOW.

    gdb/testsuite/ChangeLog:

            PR gdb/27541
            * gdb.base/index-cache-load-twice.exp: Remove.
            * gdb.base/index-cache-load-twice.c: Remove.
            * gdb.dwarf2/per-bfd-sharing.exp: New.
            * gdb.dwarf2/per-bfd-sharing.c: New.

    Change-Id: I9ffcf1e136f3e75242f70e4e58e4ba1fd3083389

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2021-03-30 17:37 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-08  2:16 [Bug symtab/27541] New: " liangjs at pku dot edu.cn
2021-03-08  2:45 ` [Bug symtab/27541] " simark at simark dot ca
2021-03-08  5:25 ` liangjs at pku dot edu.cn
2021-03-08 17:19 ` simark at simark dot ca
2021-03-09  3:06 ` liangjs at pku dot edu.cn
2021-03-09  4:17 ` simon.marchi at polymtl dot ca
2021-03-09  4:26 ` simon.marchi at polymtl dot ca
2021-03-09  5:05 ` simon.marchi at polymtl dot ca
2021-03-10  2:47 ` brobecker at gnat dot com
2021-03-11  3:19 ` simon.marchi at polymtl dot ca
2021-03-15 17:16 ` simark at simark dot ca
2021-03-30 17:37 ` cvs-commit at gcc dot gnu.org [this message]
2021-03-30 17:38 ` cvs-commit at gcc dot gnu.org
2021-03-30 17:39 ` simark at simark dot ca
2021-06-27 18:01 ` ahmedsayeed1982 at yahoo dot com
2021-09-02 11:06 ` donipah907 at mtlcz dot com
2021-09-02 11:13 ` mark at klomp dot org
2021-09-05  7:34 ` kimolsun2020 at yahoo dot com
2021-09-06  9:08 ` focixujo at livinginsurance dot co.uk
2021-09-06  9:13 ` focixujo at livinginsurance dot co.uk
2021-09-10 19:38 ` mehmetgelisin at aol dot com
2021-10-09 11:00 ` gulsenenginar at aol dot com
2021-10-09 17:44 ` svitvitraga at gmail dot com
2021-10-18 19:58 ` ahmedsayeed1982 at hotmail dot com
2021-10-19  7:13 ` progonsaytu at gmail dot com
2021-10-24 10:01 ` glassmtech at ukr dot net
2021-11-13 19:34 ` tesaso8237 at funboxcn dot com
2021-11-19  6:37 ` aslanelli50 at gmail dot com
2021-11-22  6:48 ` gexed96894 at keagenan dot com
2021-11-24 13:41 ` allen at rockvalleymarketing dot com

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-27541-4717-fArILsZOeY@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).