Copilot commented on code in PR #13610:
URL: https://github.com/apache/trafficserver/pull/13610#discussion_r3918045969
##########
CMakeLists.txt:
##########
@@ -449,6 +450,43 @@ elseif(ENABLE_TSAN)
add_link_options(-g -fsanitize=thread)
endif()
+# UndefinedBehaviorSanitizer. Deliberately not part of the either/or chain
above:
+# UBSan instruments arithmetic, shifts, and type loads rather than replacing
the
+# allocator or the thread runtime, so it composes with either of them as well
as
+# standing on its own: asan gives -fsanitize=address,undefined and tsan gives
+# -fsanitize=thread,undefined. Only the asan pairing has a preset, since that
is
+# the combination developers ask for, but the option itself does not restrict
it.
+#
+# vptr is excluded. It needs a matching type_info at every polymorphic access,
and
+# a plugin loaded with dlopen does not reliably share type identity with the
main
+# image, so the check reports the plugin boundary rather than a real bug.
+#
+# Findings recover, so a single run reports every distinct site instead of
stopping
+# at the first. That is the default for most checks, but which checks recover
by
+# default varies between compilers, so ask for it explicitly rather than
inherit it.
+# A few checks cannot recover by construction (unreachable, return) and still
abort.
+# Set UBSAN_OPTIONS=halt_on_error=1 at runtime to stop on the first finding,
which
+# is what a gating job would want.
+if(ENABLE_UBSAN)
+ # This can fail two ways: the toolchain does not know -fsanitize=undefined
at all,
+ # or it knows the flag but cannot link the runtime library, which some
distributions
+ # package separately from the compiler. Without the check the second case
surfaces as
+ # a bare "cannot find libubsan.so" from the linker after compiling hundreds
of
+ # objects, so establish it here and let the message cover both.
+ include(CheckLinkerFlag)
+ check_linker_flag(CXX -fsanitize=undefined HAS_UBSAN_SUPPORT)
+ if(NOT HAS_UBSAN_SUPPORT)
+ message(
+ FATAL_ERROR
+ "ENABLE_UBSAN was requested, but this toolchain cannot link
-fsanitize=undefined. Either the compiler does not support the flag, or it does
and the sanitizer runtime is missing. If the compiler is GCC, that runtime is
the libubsan package."
Review Comment:
The fatal error message hard-codes a specific distro package name ("the
libubsan package"). On some platforms (e.g., Debian/Ubuntu), the GCC UBSan
runtime is packaged under different names (commonly libubsan1), so this
guidance can be misleading even though the underlying diagnosis is correct.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]