[compiler-rt] [ASan] Prevent ASan/LSan deadlock by preloading modules before error reporting (PR #131756)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 23 03:46:43 PDT 2025
Camsyn wrote:
> Just an FYI - on msvc's ASan, which is based off the llvm codebase, we're seeing the fuzzer test [`stack-overflow-with-asan.test`](https://github.com/llvm/llvm-project/blob/6f1adbdb2b6f21d81e491c9ddd307fca0d183850/compiler-rt/test/fuzzer/stack-overflow-with-asan.test) failing after this change.
>
> That test expects ASan to report stack overflow error, but after this change, the program crashes prior to being able to report the stack overflow. This is because we're adding more work (and thus more stack frames) in the `ScopedInErrorReport` constructor when we're already low on stack frame space, so we blow past the limit and exit abruptly.
>
> I haven't had the chance to test this with clang on windows, but I wanted to flag this behavior in case it's reproducible with clang. In any case, it would be great to find a fix for this deadlock that meshes will with trying to report a stack overflow.
In fact, this deadlock only occurs when LSan is enabled and `dl_iterate_phdr` is used for Stop-the-World, i.e., under the condition `#if CAN_SANITIZE_LEAKS && (SANITIZER_LINUX || SANITIZER_NETBSD)`. I think adding this restriction to the patch could resolve the issue (i.e., disabling this patch on Windows or some other systems). I will give a new PR about this tomorrow.
Previously, I didn’t do this because I thought the patch was quite general and shouldn’t cause any significant negative side effects. And indeed, I haven’t encountered any issues with it in my Linux environment :(.
https://github.com/llvm/llvm-project/pull/131756
More information about the llvm-commits
mailing list