Skip to content

Commit 5d159fb

Browse files
authored
[ci] Add ubsan support (#917)
* [ci] Add ubsan support * [test] Bury Interpreter to avoid LSan noise from CppInterOp#887. Interpreter_ExternalInterpreter intentionally gives up ownership of its std::unique_ptr<Interpreter> because running the destructor trips the teardown-order issue tracked in CppInterOp#887. The bare release() leaves the pointer unreachable at exit, so LSan classified the whole CompilerInstance graph (IdentifierTable, Preprocessor, Builtin identifiers, JIT modules) as ~1 MB of leaks across ~1000 allocations in the ASan+UBSan sanitizer job. Switch release() to llvm::BuryPointer, which parks the pointer in a static GraveYard so LSan sees the graph as reachable via that global. The Interpreter still lives for program lifetime; only the LSan classification changes.
1 parent ce479ce commit 5d159fb

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ jobs:
8282
clang-runtime: '22'
8383
llvm_enable_projects: "clang"
8484
llvm_targets_to_build: "host;NVPTX"
85-
- name: ubu24-x86-gcc12-clang-repl-22-asan
85+
- name: ubu24-x86-clang22-clang-repl-22-asan-ubsan
8686
os: ubuntu-24.04
87-
compiler: gcc-12
87+
compiler: clang-22
8888
clang-runtime: '22'
8989
llvm_enable_projects: "clang"
9090
llvm_targets_to_build: "host;NVPTX"
91-
sanitizer: "Address"
91+
sanitizer: "Address;Undefined"
9292
python-version: '3.14'
9393
- name: ubu24-x86-gcc12-clang-repl-21-cppyy
9494
os: ubuntu-24.04

unittests/CppInterOp/InterpreterTest.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "llvm/ADT/SmallString.h"
2020
#include "llvm/Config/llvm-config.h"
21+
#include "llvm/Support/BuryPointer.h"
2122
#include "llvm/Support/FileSystem.h"
2223
#include "llvm/Support/Path.h"
2324

@@ -466,7 +467,10 @@ TYPED_TEST(CPPINTEROP_TEST_MODE, Interpreter_ExternalInterpreter) {
466467
EXPECT_TRUE(Cpp::GetInterpreter()) << "External Interpreter not set";
467468

468469
#ifndef CPPINTEROP_USE_CLING
469-
I.release();
470+
// Skip Interpreter destruction: the teardown-order bug tracked in
471+
// CppInterOp#887 makes it unsafe. BuryPointer is used instead of
472+
// release() so LSan sees the graph as reachable rather than leaked.
473+
llvm::BuryPointer(std::move(I));
470474
#endif
471475

472476
#ifdef CPPINTEROP_USE_CLING

0 commit comments

Comments
 (0)