Unbreak ASan runtime in the simulators. #1103
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 toputenv()
it trippedan interceptor for
strchr()
which saw the memory was poisoned andraised an ASan issue.
The memory was poisoned because
AtosSymbolizerProcess
objectsare 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 thefollowing DCHECK would crash because
internal_strcmp()
doesn'twork 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)