bryancall commented on code in PR #13610: URL: https://github.com/apache/trafficserver/pull/13610#discussion_r3915760590
########## CMakeLists.txt: ########## @@ -449,6 +450,23 @@ 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 an asan build +# (-fsanitize=address,undefined) as well as standing on its own. +# +# 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 are non-fatal by default so a single run reports every distinct site +# instead of stopping at the first. Set UBSAN_OPTIONS=halt_on_error=1 at runtime +# to abort instead, which is what a gating job would want. +if(ENABLE_UBSAN) + add_compile_options(-g -fsanitize=undefined -fno-sanitize=vptr -fno-omit-frame-pointer) + add_link_options(-g -fsanitize=undefined -fno-sanitize=vptr) +endif() Review Comment: Good catch, fixed in 400c90435d. `-fsanitize=undefined` links against a runtime that some distributions package separately from the compiler. Fedora ships libasan with gcc but puts libubsan in its own package, so a GCC build here compiled 55 objects and then failed with ``` ld.bfd: cannot find /usr/lib64/libubsan.so.1.0.0: No such file or directory ``` with nothing connecting that to the option that caused it. There is now a `check_linker_flag` at configure time that fails immediately and names the missing package. Confirmed both directions: GCC without libubsan stops at configure in a few seconds, clang reports `HAS_UBSAN_RUNTIME - Success` and builds. Worth noting `ENABLE_TSAN` has the same latent problem on this platform, since libtsan is also a separate package, but that is pre-existing and I would rather fix it separately than widen this change. -- 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]
