Skip to content

[llvm-debuginfo-analyzer] Fix a couple of unhandled DWARF situations leading to a crash #1

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

Conversation

jalopezg-git
Copy link

@jalopezg-git jalopezg-git commented Apr 24, 2025

This pull request fixes a couple of unhandled situations in DWARF input leading to a crash. Specifically,

  • If the DWARF input contains a declaration of a C variadic function (where ... translates to DW_TAG_unspecified_parameters), which is then followed by a definition, llvm_unreachable() is hit in LVScope::addMissingElements().
    This is only visible in Debug builds (see stack trace below), but still. test-dwarf-clang-unspec-params.elf triggers this condition.
Invalid symbol kind.
UNREACHABLE executed at /home/jalopezg/repos/llvm-project/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp:345!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: _build/Debug/bin/llvm-debuginfo-analyzer --print=all --attribute=all /tmp/test-dwarf-clang-unspec-params.elf
 #0 0x00005577295666f6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/jalopezg/repos/llvm-project/llvm/lib/Support/Unix/Signals.inc:804:22
 #1 0x0000557729566b09 PrintStackTraceSignalHandler(void*) /home/jalopezg/repos/llvm-project/llvm/lib/Support/Unix/Signals.inc:880:1
 #2 0x0000557729563f1f llvm::sys::RunSignalHandlers() /home/jalopezg/repos/llvm-project/llvm/lib/Support/Signals.cpp:105:20
 #3 0x0000557729565fb4 SignalHandler(int, siginfo_t*, void*) /home/jalopezg/repos/llvm-project/llvm/lib/Support/Unix/Signals.inc:418:13
 #4 0x00007fc5ff23e710 (/usr/lib/libc.so.6+0x3e710)
 #5 0x00007fc5ff28e83c (/usr/lib/libc.so.6+0x8e83c)
 #6 0x00007fc5ff23e668 gsignal (/usr/lib/libc.so.6+0x3e668)
 #7 0x00007fc5ff2264b8 abort (/usr/lib/libc.so.6+0x264b8)
 #8 0x00005577294ad073 bindingsErrorHandler(void*, char const*, bool) /home/jalopezg/repos/llvm-project/llvm/lib/Support/ErrorHandling.cpp:223:55
 #9 0x0000557728f56b0c llvm::logicalview::LVScope::addMissingElements(llvm::logicalview::LVScope*) /home/jalopezg/repos/llvm-project/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp:322:5
#10 0x0000557728f5f4b7 llvm::logicalview::LVScopeFunction::resolveReferences() /home/jalopezg/repos/llvm-project/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp:1773:9
  • Parsing of instructions in LVBinaryReader::createInstructions() does not check whether Offset lies within the Bytes ArrayRef. A specially crafted DWARF input can lead to this condition.

__
NOTE: this PR is a backport of upstream llvm#137221 to the zmpr-b-llvmorg-19.1.1-patches branch. Such branch is forked from upstream tag llvmorg-19.1.1.

FYI @peledins-zimperium.

@jalopezg-git jalopezg-git added the bug Something isn't working label Apr 24, 2025
@jalopezg-git jalopezg-git force-pushed the zmpr-b-llvmorg-19.1.1-logicalview-fixes branch from 7275173 to f5bbbef Compare April 25, 2025 10:34
Copy link
Author

@jalopezg-git jalopezg-git left a comment

Choose a reason for hiding this comment

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

Thank you for review 👍; replied to your comments; PTAL.

Copy link

@peledins-zimperium peledins-zimperium left a comment

Choose a reason for hiding this comment

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

Thanks!

@jalopezg-git jalopezg-git force-pushed the zmpr-b-llvmorg-19.1.1-logicalview-fixes branch from f5bbbef to 74d31a8 Compare April 25, 2025 12:12
@jalopezg-git jalopezg-git merged commit b842f92 into Zimperium:zmpr-b-llvmorg-19.1.1-patches Apr 25, 2025
2 checks passed
@jalopezg-git jalopezg-git deleted the zmpr-b-llvmorg-19.1.1-logicalview-fixes branch April 25, 2025 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants