Skip to content

Hotfix: Crash when parsing two object files #81

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
May 16, 2024

Conversation

fosterbrereton
Copy link
Contributor

@fosterbrereton fosterbrereton commented May 16, 2024

@bheath-adobe found a pair of object files that was causing ORC to crash. This set of changes fixes the crash.

Details of the changes:

  • The compilation unit header offset is now passed to fetch_one_die. It was assuming the top of __debug_info sufficed for this value, which is true for the first compilation unit in the .o file. (Most .o files have a single compilation unit, so this "worked".) One of the sample files @bheath-adobe gave me has multiple compilation units in the .o file, and one of the successive ones was needed for ODRV processing. This caused fetch_one_die to crash trying to read from the top of __debug_info when it should have been reading relative to the successive compilation unit header when trying to resolve a type.
    • I also made improvements to distinguish between the offset to the compilation unit header and the offset to the compilation unit die, which are two related but separate things.
  • refN attribute values are now calculated relative to the compilation unit header offset (which itself is relative to the top of __debug_info). This used to be a value calculated very strangely; the new calculation is exactly what the DWARF spec expects should happen.
  • The internal terminology around variables named "address"/"offset" has been improved:
    • An ADDRESS is absolute relative to the top of the file. Address-based variables are always relative to the top of the file, so need no additional annotation.
    • An OFFSET is relative to either __debug_info or the start of the compilation unit (whose offset is relative to __debug_info.) Offsets should always be annotated with what their value is relative to.
    • Going forward, all DWARF/DIE/scanning related variables should follow the above conventions.
  • A handful of improvements were made to some freader routines, courtesy of @bheath-adobe.
  • Improvements made to self-referential type deduction (Honestly I'm still not entirely sure what this is.)

@fosterbrereton fosterbrereton marked this pull request as ready for review May 16, 2024 17:38
Copy link
Contributor

@leethomason leethomason left a comment

Choose a reason for hiding this comment

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

LGTM. Surprisingly small fix.

@fosterbrereton fosterbrereton merged commit 50ca429 into main May 16, 2024
3 checks passed
@fosterbrereton fosterbrereton deleted the fosterbrereton/hotfix branch May 16, 2024 18:55
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