public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Ruud van der Pas <ruud.vanderpas@oracle.com>
To: Gilles DUBOSCQ <gilles.m.duboscq@oracle.com>
Cc: "binutils@sourceware.org" <binutils@sourceware.org>
Subject: Re: gprofng SIGSEGV when processing unusual dwarf
Date: Mon, 6 Feb 2023 20:28:00 +0000	[thread overview]
Message-ID: <02347EFE-BA80-42E8-8AE3-214501F5AF95@oracle.com> (raw)
In-Reply-To: <BLAPR10MB52986899D13C84F0505C23CEABDA9@BLAPR10MB5298.namprd10.prod.outlook.com>

Hi Gilles,

Thank you very much for your posting.

> When running gprofng display text on some executables that contain unusual dwarf data I am getting a segfault.
> In particular, the input dwarf has some compilation units (DW_TAG_compile_unit) that have neither DW_AT_comp_dir nor DW_AT_stmt_list.

I'm sorry to hear this.

> The issue is that when that happens, DwrCU::stmt_list_offset remains 0, as a result, in Dwarf::archive_Dwarf, the `get_dwrLineReg` call will process whatever is at offset 0 in .debug_line.
> Then while looking for source files, `DwrLineRegs::getPath` will potentially try to use include_directories->fetch (0) which is NULL (no comp_dir attribute).
> This leads to a segfault in StringBuilder::append.

Thanks for the analysis of the root cause of the segfault!

> A quick local test show that the issue goes away with the change below.
> The change in DwrLineRegs::getPath is not strictly necessary but makes the code more robust if some compilation unit has stmt_list but not comp_dir.

That sounds really good. Thank you for working on a fix!

> Does it make sense? How could we get a fix for this integrated?

We can take your changes, do some more testing, and then submit a patch.

> If that helps, I can create a bugzilla issue.

Thanks.

Although even more work for you, tracking these things in bugzilla helps.

Others can then more easily check whether they're running into the same problem
and we can connect an upcoming patch with the bugzilla id.

But if this is too much work for you, we can also do this.

Kind regards, Ruud

  reply	other threads:[~2023-02-06 20:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06 16:37 Gilles DUBOSCQ
2023-02-06 20:28 ` Ruud van der Pas [this message]
2023-02-07  8:45   ` Gilles DUBOSCQ
2023-02-07  9:39     ` Gilles DUBOSCQ
2023-02-07 22:44       ` Vladimir Mezentsev
2023-02-08  8:30         ` Gilles DUBOSCQ

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=02347EFE-BA80-42E8-8AE3-214501F5AF95@oracle.com \
    --to=ruud.vanderpas@oracle.com \
    --cc=binutils@sourceware.org \
    --cc=gilles.m.duboscq@oracle.com \
    /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).