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

Detect use-after-scope bugs with AddressSanitizer #68572

Merged
merged 3 commits into from Jan 29, 2020

Conversation

@tmiasko
Copy link

tmiasko commented Jan 27, 2020

Enable use-after-scope checks by default when using AddressSanitizer.
They allow to detect incorrect use of stack objects after their scope
have already ended. The detection is based on LLVM lifetime intrinsics.

To facilitate the use of this functionality, the lifetime intrinsics are
now emitted regardless of optimization level if enabled sanitizer makes
use of them.

Tomasz Miąsko added 3 commits Jan 27, 2020
Enable use-after-scope checks by default when using AddressSanitizer.
They allow to detect incorrect use of stack objects after their scope
have already ended. The detection is based on LLVM lifetime intrinsics.

To facilitate the use of this functionality, the lifetime intrinsics are
now emitted regardless of optimization level if enabled sanitizer makes
use of them.
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 27, 2020

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @QuietMisdreavus (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@nikic

This comment has been minimized.

Copy link
Contributor

nikic commented Jan 27, 2020

Does this need to be exposed as an option, similar to msan origin tracking? I know that it can be disabled via ASAN_OPTIONS at runtime, but wondering if there are any salient reasons to disable the instrumentation itself (like performance).

@tmiasko

This comment has been minimized.

Copy link
Author

tmiasko commented Jan 27, 2020

I think a new option is unnecessary. Use-after-scope has been enabled by
default in clang for some time now https://reviews.llvm.org/D31479.

Of course, in the case anyone would like to have a flag, I can add one.

@nikic

This comment has been minimized.

Copy link
Contributor

nikic commented Jan 27, 2020

I think we're fine without the flag until someone has a use-case for it...

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 27, 2020

📌 Commit 47fd27a has been approved by nikic

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 29, 2020

⌛️ Testing commit 47fd27a with merge edb3684...

bors added a commit that referenced this pull request Jan 29, 2020
Detect use-after-scope bugs with AddressSanitizer

Enable use-after-scope checks by default when using AddressSanitizer.
They allow to detect incorrect use of stack objects after their scope
have already ended. The detection is based on LLVM lifetime intrinsics.

To facilitate the use of this functionality, the lifetime intrinsics are
now emitted regardless of optimization level if enabled sanitizer makes
use of them.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 29, 2020

☀️ Test successful - checks-azure
Approved by: nikic
Pushing edb3684 to master...

@bors bors added the merged-by-bors label Jan 29, 2020
@bors bors merged commit 47fd27a into rust-lang:master Jan 29, 2020
5 checks passed
5 checks passed
homu Test successful
Details
pr Build #20200127.32 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-7) Linux x86_64-gnu-llvm-7 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 29, 2020

📣 Toolstate changed by #68572!

Tested on commit edb3684.
Direct link to PR: #68572

💔 rustc-guide on linux: test-pass → test-fail (cc @JohnTitor @amanjeev @spastorino @mark-i-m, @rust-lang/infra).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Jan 29, 2020
Tested on commit rust-lang/rust@edb3684.
Direct link to PR: <rust-lang/rust#68572>

💔 rustc-guide on linux: test-pass → test-fail (cc @JohnTitor @amanjeev @spastorino @mark-i-m, @rust-lang/infra).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.