mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
fix: Build Boost.Context with ucontext backend for TSAN builds
TSAN cannot instrument fcontext (assembly) context switches, causing undefined symbol errors for fiber_activation_record::current(). Add Conan build options and CMake defines to use the ucontext backend for TSAN, matching the existing ASAN configuration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -61,3 +61,14 @@ if(enable_asan)
|
||||
INTERFACE BOOST_USE_ASAN BOOST_USE_UCONTEXT
|
||||
)
|
||||
endif()
|
||||
|
||||
# TSAN also requires the ucontext backend so that Boost.Context uses
|
||||
# POSIX ucontext (not fcontext assembly) for fiber switching. This
|
||||
# allows TSAN to properly track context switches and avoids false positives.
|
||||
# These defines must match what Boost was compiled with (see conan/profiles/sanitizers).
|
||||
if(enable_tsan)
|
||||
target_compile_definitions(
|
||||
xrpl_boost
|
||||
INTERFACE BOOST_USE_TSAN BOOST_USE_UCONTEXT
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -82,5 +82,12 @@ tools.info.package_id:confs+=["tools.build:cxxflags", "tools.build:exelinkflags"
|
||||
boost/*:without_context=False
|
||||
# Boost stacktrace fails to build with some sanitizers
|
||||
boost/*:without_stacktrace=True
|
||||
{% elif "thread" in sanitizers %}
|
||||
# Build Boost.Context with ucontext backend (not fcontext) so that
|
||||
# TSAN can instrument fiber/context switches. fcontext uses raw assembly
|
||||
# which TSAN cannot intercept, causing false positives and link errors.
|
||||
boost/*:extra_b2_flags=context-impl=ucontext thread-sanitizer=on define=BOOST_USE_TSAN=1
|
||||
boost/*:without_context=False
|
||||
boost/*:without_stacktrace=True
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user