gprofng SIGSEGV when processing unusual dwarf

Ruud van der Pas ruud.vanderpas@oracle.com
Mon Feb 6 20:28:00 GMT 2023


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


More information about the Binutils mailing list