Issue 127347
Summary [libc++][sanitizer] Pass through *SAN_OPTIONS= env into tests
Labels libc++
Assignees vitalybuka
Reporter vitalybuka
    1. Checkout e5f4019f69948f55b77fcb5f63ae8c296418432c or any between #124103 and #126995
2. cmake like https://lab.llvm.org/buildbot/#/builders/sanitizer-x86_64-linux-bootstrap-asan
```
/usr/bin/cmake -B libcxx_build_asan -DLLVM_APPEND_VC_REV=OFF -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_CCACHE_BUILD=ON -DLLVM_USE_LINKER=lld -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_C_COMPILER=/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang -DCMAKE_CXX_COMPILER=/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang++ -DLIBCXXABI_USE_LLVM_UNWINDER=OFF -DCMAKE_INSTALL_PREFIX=/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan '-DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi' -DLIBCXX_TEST_PARAMS=long_tests=False -DLIBCXX_INCLUDE_BENCHMARKS=OFF -DLLVM_USE_SANITIZER=Address '-DCMAKE_C_FLAGS=-fsanitize=address  ' '-DCMAKE_CXX_FLAGS=-fsanitize=address  ' /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/../runtimes
```
3. Add test similar to #126995 but without default options.
```
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include <iostream>

// Test that ios used from globals constructors doesn't trigger Asan initialization-order-fiasco.

struct Global {
  Global() { std::cout << "Hello!"; }
} global;

int main(int, char**) { return 0; }
```
4. Run LIT with additional Asan options
```
ASAN_OPTIONS=check_initialization_order=true:strict_init_order=true LIT_FILTER=global ninja -C libcxx_build_asan check-cxx
```

Expected: the test fails with "AddressSanitizer: initialization-order-fiasco"

Actuall: the test passes

ASAN_OPTIONS does not reach test executable. Somewhere in the middle env is removes the var.

We need to do something like llvm-project/clang/test/Unit/lit.cfg.py

```
# Propagate sanitizer options.
for var in [
    "ASAN_SYMBOLIZER_PATH",
 "HWASAN_SYMBOLIZER_PATH",
    "MSAN_SYMBOLIZER_PATH",
 "TSAN_SYMBOLIZER_PATH",
    "UBSAN_SYMBOLIZER_PATH",
 "ASAN_OPTIONS",
    "HWASAN_OPTIONS",
    "MSAN_OPTIONS",
 "TSAN_OPTIONS",
    "UBSAN_OPTIONS",
]:
    if var in os.environ:
 config.environment[var] = os.environ[var]
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to