Skip to content

Detect use-after-scope bugs with AddressSanitizer #68572

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 3 commits into from
Jan 29, 2020

Conversation

tmiasko
Copy link
Contributor

@tmiasko 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.

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
Copy link
Contributor

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 27, 2020
@nikic
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
Copy link
Contributor 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
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
Copy link
Collaborator

bors commented Jan 27, 2020

📌 Commit 47fd27a has been approved by nikic

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 27, 2020
@bors
Copy link
Collaborator

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
Copy link
Collaborator

bors commented Jan 29, 2020

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 29, 2020
@bors bors merged commit 47fd27a into rust-lang:master Jan 29, 2020
@rust-highfive
Copy link
Contributor

📣 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).
@tmiasko tmiasko deleted the sanitizer-use-after-scope branch February 27, 2020 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants