Skip to content
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

Don't truncate ranges of units #163

Merged
merged 2 commits into from
May 13, 2020

Conversation

alexcrichton
Copy link
Contributor

This commit is an attempt to fix rust-lang/backtrace-rs#327. The
behavior seen there was that CGUs would often overlap each other which
would cause a previous loop which tried to ensure CGUs didn't overlap to
avoid some CGUs being candidates for symbolizing.

To fix the issue this commit removes the loop which alters the range of
each CGU. Instead CGUs are only sorted by their starting function
address. When looking up a CGU for a function the CGU's address range is
used to initially filter the sort but afterwards the units function
address table is also consulted. The first CGU which contains the
function address is what ends up getting returned.

This commit is an attempt to fix rust-lang/backtrace-rs#327. The
behavior seen there was that CGUs would often overlap each other which
would cause a previous loop which tried to ensure CGUs didn't overlap to
avoid some CGUs being candidates for symbolizing.

To fix the issue this commit removes the loop which alters the range of
each CGU. Instead CGUs are only sorted by their starting function
address. When looking up a CGU for a function the CGU's address range is
used to initially filter the sort but afterwards the units function
address table is also consulted. The first CGU which contains the
function address is what ends up getting returned.
@alexcrichton
Copy link
Contributor Author

Ok and now with tests for macos!

src/lib.rs Outdated
// No exact match was found, but this probe would fit at slot `i`.
// This means that slot `i-1` is the highest start address which is
// underneath `probe`, which is the CGU we'd like to start
// searching.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: DWARF calls them compilation units (CU).

Given that CUs can be much larger than needed, it's not clear to me that this is the CU we need to start at. Why can't there be a CU with a lower start address that contains the probe address?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm yes I'm entirely mixed up in how sorting works, let me see if I can find a solution which actually works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I think the new logic should work out!

Copy link
Contributor

@philipc philipc left a comment

Choose a reason for hiding this comment

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

Thanks!

Do you want a patch release with this?

small::test_function as u64,
"correctness::small::test_function",
);
test(aux::foo as u64, "aux::foo");
Copy link
Contributor

Choose a reason for hiding this comment

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

What are these two tests checking that wasn't covered before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The small module was me attempting to reproduce the original issue and the aux::foo test will fail on macOS before this PR but succeeds after this PR. I'm not entirely sure what makes rustc generate the object that causes this but w/e it is it seems to work.

@alexcrichton
Copy link
Contributor Author

Nah this isn't urgent, just something I noticed. Should be fine to defer a release!

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.

Backtrace example doesn't have all line numbers on macOS
2 participants