Skip to content

Unbreak ASan runtime in the simulators. #1103

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

Conversation

danliew-apple
Copy link

Summary:
861b69f (rdar://problem/58789439) while
fixing symbolization for TSan completely broke ASan's runtime for the
simulators.

The problem with the previous patch is that the memory passed to
putenv() was poisoned and when passed to putenv() it tripped
an interceptor for strchr() which saw the memory was poisoned and
raised an ASan issue.

The memory was poisoned because AtosSymbolizerProcess objects
are created using ASan's internal allocator. Memory from this
allocator gets poisoned with kAsanInternalHeapMagic.

To workaround this, this patch makes the memory for the environment
variable entry a global variable that isn't poisoned.

This pass also adds a DCHECK(getenv(K_ATOS_ENV_VAR)) because the
following DCHECK would crash because internal_strcmp() doesn't
work on nullptr.

rdar://problem/62067724

Reviewers: kubamracek, yln

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D78525

(cherry picked from commit 7039773)

Summary:
861b69f (rdar://problem/58789439) while
fixing symbolization for TSan completely broke ASan's runtime for the
simulators.

The problem with the previous patch is that the memory passed to
`putenv()` was poisoned and when passed to `putenv()` it tripped
an interceptor for `strchr()` which saw the memory was poisoned and
raised an ASan issue.

The memory was poisoned because `AtosSymbolizerProcess` objects
are created using ASan's internal allocator. Memory from this
allocator gets poisoned with `kAsanInternalHeapMagic`.

To workaround this, this patch makes the memory for the environment
variable entry a global variable that isn't poisoned.

This pass also adds a `DCHECK(getenv(K_ATOS_ENV_VAR))` because the
following DCHECK would crash because `internal_strcmp()` doesn't
work on nullptr.

rdar://problem/62067724

Reviewers: kubamracek, yln

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D78525

(cherry picked from commit 7039773)
@danliew-apple
Copy link
Author

@swift-ci please test.

@danliew-apple danliew-apple merged commit c94d846 into swiftlang:apple/stable/20200108 Apr 22, 2020
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