[Bug debugedit/32845] New: assert triggers for missing debug_str_offsets entry

mark at klomp dot org sourceware-bugzilla@sourceware.org
Mon Apr 7 11:58:35 GMT 2025


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

            Bug ID: 32845
           Summary: assert triggers for missing debug_str_offsets entry
           Product: debugedit
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: debugedit
          Assignee: mark at klomp dot org
          Reporter: mark at klomp dot org
                CC: debugedit at sourceware dot org, jakub at redhat dot com
  Target Milestone: ---

The debugedit code assumes that all string indexes point to actually used debug
strings. But we have seen at least one case where webkitgtk compiled with
clang++ produces .debug_str_offset entries pointing to a string
("CrossThreadCopierBaseHelper" in this case) which isn't actually used in any
of the other debuginfo sections.

So the assert in string_find_entry triggers saying "heay there is this idx into
the string table, that you want me to rewrite, but I never saw this string
(idx) before" because it assumes there are no .debug_str_offsets that aren't
actually used... Which normally would be a good safety check, because it means
we failed to properly parse the full debuginfo and missed some use of the
string (which should have possibly been rewritten). But in this case it seems
to be a false assumption. Maybe some optimization left the string behind while
optimizing away the debug reference?

The assert was there to make sure we processed all strings. The code really
expects all strings reachable through the .debug_str_offsets are actually used
in the rest of the debug sections. That way it only had to rewrite the index
entries, keeping the size and headers the same. For a proper fix we need to do
an extra pass over the .debug_str_offets to check all indexes actually point to
used strings and if not, either add the unused string so it gets into the new
.debug_str (possibly at a new index) or we throw it out and rewrite the headers
and size of the str_offsets tables (but that would also mean rewriting the refs
to them, which would be a pain because that also means rewriting the strx
indexes, which are variable lenght, so we don't want to do that).

The best fix, suggested by Jakub, seems to be to have a dummy "" (or maybe
"<debugedit>" string) in the .debug_str section and rewrite all "missing
strings" to that. Which prevents having to do another full pass over the
.debug_str_offsets. And probably emit a warning because it is bad (suboptimal)
debuginfo generated by the compiler.

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


More information about the Debugedit mailing list