diff --git a/cmake/XrplSanitizers.cmake b/cmake/XrplSanitizers.cmake index afe58b8fab..f279f23796 100644 --- a/cmake/XrplSanitizers.cmake +++ b/cmake/XrplSanitizers.cmake @@ -25,18 +25,18 @@ * -O1: Minimum optimization for reasonable performance * -fsanitize=: Enables sanitizer instrumentation * -fsanitize-ignorelist=: (Clang only) Compile-time ignorelist - * -mcmodel=medium: (GCC only) Code model for large binaries + * -mcmodel=large: (GCC only) Code model for large binaries * -Wno-stringop-overflow: (GCC only) Suppresses false positive warnings * -Wno-tsan: (For GCC TSAN combination only) Suppresses atomic_thread_fence warnings - SANITIZERS_LINK_FLAGS: Linker flags for sanitizer runtime libraries. Includes: * -fsanitize=: Links sanitizer runtime libraries - * -mcmodel=medium: (GCC only) Matches compile-time code model + * -mcmodel=large: (GCC only) Matches compile-time code model - SANITIZERS_RELOCATION_FLAGS: (GCC only) Code model flags for linking. Used to handle large instrumented binaries on x86_64: - * -mcmodel=medium: For both ASAN and TSAN (large model collides with + * -mcmodel=large: For both ASAN and TSAN (large model collides with * ASAN shadow memory; is incompatible with TSAN) #]===================================================================] @@ -147,9 +147,9 @@ if(is_gcc) list(APPEND SANITIZERS_COMPILE_FLAGS "-Wno-stringop-overflow") if(is_amd64 AND enable_asan) - message(STATUS " Using medium code model (-mcmodel=medium)") - list(APPEND SANITIZERS_COMPILE_FLAGS "-mcmodel=medium") - list(APPEND SANITIZERS_RELOCATION_FLAGS "-mcmodel=medium") + message(STATUS " Using large code model (-mcmodel=large)") + list(APPEND SANITIZERS_COMPILE_FLAGS "-mcmodel=large") + list(APPEND SANITIZERS_RELOCATION_FLAGS "-mcmodel=large") elseif(enable_tsan) # GCC doesn't support atomic_thread_fence with tsan. Suppress warnings. list(APPEND SANITIZERS_COMPILE_FLAGS "-Wno-tsan") diff --git a/cmake/deps/Boost.cmake b/cmake/deps/Boost.cmake index 3b4e165dcf..80c652f0ac 100644 --- a/cmake/deps/Boost.cmake +++ b/cmake/deps/Boost.cmake @@ -55,20 +55,13 @@ endif() # stack-use-after-scope errors. BOOST_USE_UCONTEXT ensures the ucontext backend # is selected (fcontext does not support ASAN annotations). # These defines must match what Boost was compiled with (see conan/profiles/sanitizers). -if(enable_asan) +# 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_asan OR enable_tsan) target_compile_definitions( xrpl_boost 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() diff --git a/conan/profiles/sanitizers b/conan/profiles/sanitizers index 85827558b0..7fb59a8250 100644 --- a/conan/profiles/sanitizers +++ b/conan/profiles/sanitizers @@ -13,7 +13,7 @@ include(default) {% if "address" in sanitizers %} {% set _ = sanitizer_list.append("address") %} - {% set model_code = "-mcmodel=medium" %} + {% set model_code = "-mcmodel=large" %} {% set _ = defines.append("BOOST_USE_ASAN")%} {% set _ = defines.append("BOOST_USE_UCONTEXT")%} {% elif "thread" in sanitizers %} diff --git a/include/xrpl/beast/test/yield_to.h b/include/xrpl/beast/test/yield_to.h index bbbc0f094a..45849c94fe 100644 --- a/include/xrpl/beast/test/yield_to.h +++ b/include/xrpl/beast/test/yield_to.h @@ -29,15 +29,15 @@ namespace test { * constraint). */ #if defined(__SANITIZE_THREAD__) || defined(__SANITIZE_ADDRESS__) -inline constexpr std::size_t yieldStackSize = 4 * 1024 * 1024; +inline constexpr std::size_t yieldStackSize = 2 * 1024 * 1024; #elif defined(__has_feature) #if __has_feature(thread_sanitizer) || __has_feature(address_sanitizer) -inline constexpr std::size_t yieldStackSize = 4 * 1024 * 1024; -#else inline constexpr std::size_t yieldStackSize = 2 * 1024 * 1024; +#else +inline constexpr std::size_t yieldStackSize = 1.5 * 1024 * 1024; #endif #else -inline constexpr std::size_t yieldStackSize = 2 * 1024 * 1024; +inline constexpr std::size_t yieldStackSize = 1.5 * 1024 * 1024; #endif /** Mix-in to support tests using asio coroutines. diff --git a/include/xrpl/core/Coro.ipp b/include/xrpl/core/Coro.ipp index 100eace558..be3681e75c 100644 --- a/include/xrpl/core/Coro.ipp +++ b/include/xrpl/core/Coro.ipp @@ -12,7 +12,7 @@ namespace xrpl { * Sanitizers significantly increase stack frame sizes * (TSAN ~3-5x, ASAN ~2-3x), requiring larger coroutine stacks. */ -inline constexpr std::size_t coroStackSize = XRPL_SANITIZER_ACTIVE ? megabytes(4) : megabytes(2); +inline constexpr std::size_t coroStackSize = XRPL_SANITIZER_ACTIVE ? megabytes(2) : megabytes(1.5); template JobQueue::Coro::Coro(Coro_create_t, JobQueue& jq, JobType type, std::string const& name, F&& f) diff --git a/include/xrpl/resource/ResourceManager.h b/include/xrpl/resource/ResourceManager.h index 10ad471898..54bcf4e14e 100644 --- a/include/xrpl/resource/ResourceManager.h +++ b/include/xrpl/resource/ResourceManager.h @@ -23,10 +23,8 @@ public: virtual ~Manager() = 0; /** Start the manager's background thread. - Must be called after construction to begin periodic charge decay and inactive-consumer sweeps. - @note Not thread-safe. Must be called exactly once, before any concurrent access to the manager. */ diff --git a/src/xrpld/app/main/BasicApp.h b/src/xrpld/app/main/BasicApp.h index 6e92181a54..fb0c172323 100644 --- a/src/xrpld/app/main/BasicApp.h +++ b/src/xrpld/app/main/BasicApp.h @@ -7,10 +7,8 @@ #include /** Manages an io_context and its worker threads. - * * Ensures the io_context outlives all derived classes by joining worker * threads in the destructor. Supports immediate or deferred thread startup. - * * @note Thread-safe after construction completes. The deferred-start * constructor and startIOThreads() must be called from a single thread. */ @@ -42,7 +40,6 @@ public: protected: /** Tag type for deferred thread startup. - * * Pass to the protected constructor to construct without starting IO * threads. The derived class must call startIOThreads() once its own * construction is complete. @@ -52,14 +49,12 @@ protected: }; /** Construct without starting IO threads. - * * @param numberOfThreads Desired number of IO worker threads. * @param Tag to select deferred startup. */ BasicApp(std::size_t numberOfThreads, DeferStart); /** Start the IO worker threads. - * * @note Must be called exactly once after the deferred-start constructor. */ void