[all-commits] [llvm/llvm-project] 0d7e64: [ASan][Windows] Honor asan config flags on windows...
David Justo via All-commits
all-commits at lists.llvm.org
Wed Jul 2 15:37:50 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0d7e64f5d2b45e2150a89390cfdc69b19b1493d9
https://github.com/llvm/llvm-project/commit/0d7e64f5d2b45e2150a89390cfdc69b19b1493d9
Author: David Justo <david.justo.1996 at gmail.com>
Date: 2025-07-02 (Wed, 02 Jul 2025)
Changed paths:
M compiler-rt/lib/asan/asan_allocator.cpp
M compiler-rt/lib/asan/asan_allocator.h
M compiler-rt/lib/asan/asan_flags.cpp
M compiler-rt/lib/asan/asan_internal.h
M compiler-rt/lib/asan/asan_rtl.cpp
A compiler-rt/test/asan/TestCases/Windows/alloc_dealloc_mismatch.cpp
Log Message:
-----------
[ASan][Windows] Honor asan config flags on windows when set through the user function (#122990)
**Related to:** https://github.com/llvm/llvm-project/issues/117925
**Follow up to:** https://github.com/llvm/llvm-project/pull/117929
**Context:**
As noted in the linked issue, some ASan configuration flags are not
honored on Windows when set through the `__asan_default_options` user
function. The reason for this is that `__asan_default_options` is not
available by the time `AsanInitInternal` executes, which is responsible
for applying the ASan flags.
To fix this properly, we'll probably need a deep re-design of ASan
initialization so that it is consistent across OS'es.
In the meantime, this PR offers a practical workaround.
**This PR:** refactors part of `AsanInitInternal` so that **idempotent**
flag-applying steps are extracted into a new function `ApplyOptions`.
This function is **also** invoked in the "weak function callback" on
Windows (which gets called when `__asan_default_options` is available)
so that, if any flags were set through the user-function, they are
safely applied _then_.
Today, `ApplyOptions` contains only a subset of flags. My hope is that
`ApplyOptions` will over time, through incremental refactorings
`AsanInitInternal` so that **all** flags are eventually honored.
Other minor changes:
* The introduction of a `ApplyAllocatorOptions` helper method, needed to
implement `ApplyOptions` for allocator options without re-initializing
the entire allocator. Reinitializing the entire allocator is expensive,
as it may do a whole pass over all the marked memory. To my knowledge,
this isn't needed for the options captured in `ApplyAllocatorOptions`.
* Rename `ProcessFlags` to `ValidateFlags`, which seems like a more
accurate name to what that function does, and prevents confusion when
compared to the new `ApplyOptions` function.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list