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

Make ASAN actually do something and fix all the things #46336

Merged
merged 1 commit into from
Aug 17, 2022
Merged

Conversation

Keno
Copy link
Member

@Keno Keno commented Aug 12, 2022

We've had the ability to build with ASAN for quite a while, but
at some point the LLVM pass stopped doing anything unless you
also annotated the function with the sanitize_address attribute,
so if you built Julia with asan enabled, very few things were
actually built with asan and those that were didn't have one
of asan's most crucial features enabled: Tracking out of bounds
stack accesses.

This PR enabled asan-stack handling, adds the appropriate asan
poison handling to our tasks and fixes a plethora of other things
that didn't work with asan enabled. The result of this PR (together
with a few other PRs still pending) should be that asan passes
tests on master.

This was a significant amount of work, and the changes required
quite subtle. As a result, I think we should make sure to quickly
set up CI to test this configuration and make sure it doesn't
regress.

@Keno Keno force-pushed the kf/reviveasan branch 2 times, most recently from 8a04e68 to 1acecb7 Compare August 13, 2022 02:22
Keno added a commit that referenced this pull request Aug 15, 2022
Analogous to (and dependent on) #46336, but for msan. The biggest
change is a workaround for LLVM's lack for TLS relocation support
(I had a fix for that about 7 years ago at https://reviews.llvm.org/D8815,
but that was x86_64-linux-gnu only, while this workaround works
everywhere - though we should consider resurrecting my patch for
performance at some point). The rest is mostly build fixes and
plumbing to get the sanitizer flags through to the dependencies.
We've had the ability to build with ASAN for quite a while, but
at some point the LLVM pass stopped doing anything unless you
also annotated the function with the `sanitize_address` attribute,
so if you built Julia with asan enabled, very few things were
actually built with asan and those that were didn't have one
of asan's most crucial features enabled: Tracking out of bounds
stack accesses.

This PR enabled asan-stack handling, adds the appropriate asan
poison handling to our tasks and fixes a plethora of other things
that didn't work with asan enabled. The result of this PR (together
with a few other PRs still pending) should be that asan passes
tests on master.

This was a significant amount of work, and the changes required
quite subtle. As a result, I think we should make sure to quickly
set up CI to test this configuration and make sure it doesn't
regress.
@Keno Keno merged commit 9f78e04 into master Aug 17, 2022
@Keno Keno deleted the kf/reviveasan branch August 17, 2022 04:33
Keno added a commit that referenced this pull request Aug 17, 2022
Analogous to (and dependent on) #46336, but for msan. The biggest
change is a workaround for LLVM's lack for TLS relocation support
(I had a fix for that about 7 years ago at https://reviews.llvm.org/D8815,
but that was x86_64-linux-gnu only, while this workaround works
everywhere - though we should consider resurrecting my patch for
performance at some point). The rest is mostly build fixes and
plumbing to get the sanitizer flags through to the dependencies.
Keno added a commit that referenced this pull request Aug 18, 2022
Analogous to (and dependent on) #46336, but for msan. The biggest
change is a workaround for LLVM's lack for TLS relocation support
(I had a fix for that about 7 years ago at https://reviews.llvm.org/D8815,
but that was x86_64-linux-gnu only, while this workaround works
everywhere - though we should consider resurrecting my patch for
performance at some point). The rest is mostly build fixes and
plumbing to get the sanitizer flags through to the dependencies.
Keno added a commit that referenced this pull request Aug 19, 2022
Analogous to (and dependent on) #46336, but for msan. The biggest
change is a workaround for LLVM's lack for TLS relocation support
(I had a fix for that about 7 years ago at https://reviews.llvm.org/D8815,
but that was x86_64-linux-gnu only, while this workaround works
everywhere - though we should consider resurrecting my patch for
performance at some point). The rest is mostly build fixes and
plumbing to get the sanitizer flags through to the dependencies.
@@ -76,17 +76,16 @@ void jl_init_stack_limits(int ismaster, void **stack_lo, void **stack_hi)
#if defined(_COMPILER_GCC_) && __GNUC__ >= 12
#pragma GCC diagnostic ignored "-Wdangling-pointer"
#endif
*stack_hi = (void*)&stacksize;
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

why are we using &stacksize rather than the value of it as stackaddr + stacksize

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know, but the former is slightly smaller of course. I guess it may prevent us from smashing any extra information the system may have put at the stack base.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

we should never smash this; we just use it to decide if it hit a StackOverflow

@Keno Keno mentioned this pull request Oct 19, 2023
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