This is an automated email from the ASF dual-hosted git repository.
airborne12 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 973f93f51f8 [fix](build) Let ScopedLSANDisabler compile without a
sanitizer (#66049)
973f93f51f8 is described below
commit 973f93f51f8332ed77fa96d0c7ec1e8a1309522b
Author: Jack <[email protected]>
AuthorDate: Mon Jul 27 10:32:34 2026 +0800
[fix](build) Let ScopedLSANDisabler compile without a sanitizer (#66049)
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
`doris_be_test` can only be linked as an ASAN build.
`BUILD_TYPE_UT=DEBUG` and `BUILD_TYPE_UT=RELEASE`
both fail at link:
```
ld.lld: error: undefined symbol: __lsan_disable
>>> referenced by leak_annotations.h:84
>>>
cached_remote_file_reader_peer_test.cpp.o:(doris::debug::ScopedLSANDisabler::ScopedLSANDisabler())
```
`be/src/util/debug/leak_annotations.h` computes `DORIS_LSAN_ENABLED` and
uses it to guard
`ANNOTATE_LEAKING_OBJECT_PTR`, but `ScopedLSANDisabler` sits outside
every `#if`:
```cpp
class ScopedLSANDisabler {
public:
ScopedLSANDisabler() { __lsan_disable(); }
~ScopedLSANDisabler() { __lsan_enable(); }
};
```
`__lsan_disable` / `__lsan_enable` are only declared in that header;
they are defined by the
LeakSanitizer runtime. Without `-fsanitize=address` (or `=leak`) nothing
provides them, so every
translation unit that instantiates the class emits an undefined
reference. Two do —
`be/src/util/debug/leakcheck_disabler.h` and
`be/test/io/cache/cached_remote_file_reader_peer_test.cpp`.
This matters beyond tidiness: it means there is no way to produce an
optimized, un-instrumented unit
test binary, so unit tests cannot be used for any timing work — ASAN's
allocator instrumentation and
`-O0` dominate whatever is being measured.
The guard is extended to cover the class. With no LeakSanitizer there is
nothing to suppress, so it
degrades to a no-op, which is the same reasoning
`ANNOTATE_LEAKING_OBJECT_PTR` already applies.
---
be/src/util/debug/leak_annotations.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/be/src/util/debug/leak_annotations.h
b/be/src/util/debug/leak_annotations.h
index 16a289d85a0..bef2bff9f65 100644
--- a/be/src/util/debug/leak_annotations.h
+++ b/be/src/util/debug/leak_annotations.h
@@ -79,10 +79,26 @@ int __lsan_do_recoverable_leak_check();
namespace doris::debug {
+// Suppresses leak reports for allocations made in this scope.
+//
+// The __lsan_* functions above are only declared here; they are defined by
the LeakSanitizer
+// runtime. Without -fsanitize=address (or =leak) nothing provides them, so
calling them
+// unconditionally left every translation unit that instantiates this class
with an undefined
+// reference, and doris_be_test could only be linked as an ASAN build. There
is nothing to suppress
+// when no sanitizer is present, so the guard below degrades to a no-op -- the
same reasoning
+// ANNOTATE_LEAKING_OBJECT_PTR already uses.
class ScopedLSANDisabler {
public:
+#if defined(DORIS_LSAN_ENABLED)
ScopedLSANDisabler() { __lsan_disable(); }
~ScopedLSANDisabler() { __lsan_enable(); }
+#else
+ // Deliberately user-provided and not `= default`: a defaulted constructor
makes the type
+ // trivial, and every `ScopedLSANDisabler guard;` then trips
-Werror,-Wunused-variable. An
+ // empty user-provided body keeps the guard a no-op while remaining a real
RAII object.
+ ScopedLSANDisabler() {}
+ ~ScopedLSANDisabler() {}
+#endif
};
} // namespace doris::debug
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]