Skip to content

Make dwarf_init_path_a error non-fatal #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2025

Conversation

GHF
Copy link
Contributor

@GHF GHF commented May 28, 2025

I ran into an exception in the case of a "corrupted" ELF section (just unreadable by libdwarf, not corrupted). It turned out to be percolated from dwarf_init_path_a returning an error. libdwarf failing to parse an object should not inhibit falling back to parsing the ELF symtab, so I make this particular path less fatal.

I repeated ok = false; for consistency and readability but I do realize all of the appearances in the function of this line seem redundant.

libdwarf failing to parse an object should not inhibit falling back to
parsing the ELF symtab.
@jeremy-rifkin
Copy link
Owner

Thanks for opening this, I think this presents a larger question of how error reporting in cpptrace should work and I'm not sure the best approach.

An error from dwarf_init_path means something is terribly wrong with the file (or libdwarf) and that's something that needs to be reportable, somehow (trace_dwarf is really for my own internal printbugging of things, it's hard-coded to false). We'd want this reported similar to other important errors like dbghelp stuff on windows etc.

Stack traces are complicated and there are a lot of things that can go wrong, cpptrace tries to gracefully recover from everything unless absorb trace exceptions is set to false. I'm in agreement that ELF symbol table fallback should always be done even if libdwarf encounters a fatal error.

Maybe cpptrace should never throw internally unless caught quickly. There's now an alternative means of error reporting in the form of an internal logging mechanism (on the dev branch). This would probably be good to start using more instead of exceptions / absorb_trace_exceptions.

@jeremy-rifkin jeremy-rifkin changed the base branch from main to dev June 3, 2025 05:09
Copy link
Owner

@jeremy-rifkin jeremy-rifkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for taking the time to do this. I'm happy with the approach and the results. I went ahead and updated the logging.
Separately I'm doing some larger-scale work on the codebase to improve error handling, recovery, and reporting.

@jeremy-rifkin jeremy-rifkin merged commit 6f0e356 into jeremy-rifkin:dev Jun 3, 2025
99 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants