Repository navigation
Conversation
get_pool() wrote table[ix].pool_index on every call. It is called for
every buffer::raw construction and destruction, so concurrent calls
race:
WARNING: ThreadSanitizer: data race
Write of size 4 by thread T130:
#0 mempool::get_pool(mempool::pool_index_t) src/common/mempool.cc:86
ceph#1 ceph::buffer::v15_2_0::raw::raw(char*, unsigned int, int)
Previous write of size 4 by main thread:
#0 mempool::get_pool(mempool::pool_index_t) src/common/mempool.cc:86
ceph#1 ceph::buffer::v15_2_0::raw::~raw()
Set all pool_index values once, when the function-local static table is
constructed. The table was already initialized on first use, so this
adds no cost and still works from static constructors in other
translation units.
Under TSan (GCC 15.2, Debug), this removes 4,225 reports from 22 unit
tests.
Assisted-by: claude-opus-5-5
Signed-off-by: Dominik Raddatz <[email protected]>
shutdown() sets m_shutdown while the admin socket thread polls it in
entry():
WARNING: ThreadSanitizer: data race
Write of size 1 by main thread:
#0 AdminSocket::shutdown() src/common/admin_socket.cc:1145
Previous read of size 1 by thread T4:
#0 AdminSocket::entry() src/common/admin_socket.cc:302
Thread T4 'admin_socket' created by main thread
Relaxed ordering is enough: m_shutdown guards no other data, and
shutdown() joins the thread after waking it through the wakeup pipe.
Assisted-by: claude-opus-5-5
Signed-off-by: Dominik Raddatz <[email protected]>
4 of 14 tasks
tchaikov
reviewed
Nov 11, 2026
tchaikov
left a comment
Contributor
There was a problem hiding this comment.
as an alternative, probably we can have something like
{
std::lock_guard lg(_service_thread_lock);
if (_service_thread) {
return;
}
// create the counters before the thread, whose loop reads them
if (!(get_init_flags() & CINIT_FLAG_NO_CCT_PERF_COUNTERS)) {
_enable_perf_counter();
}
_service_thread = new CephContextServiceThread(this);
_service_thread->create("service");
}?
start_service_thread() started the service thread before
_enable_perf_counter() had built the counters its loop reads:
WARNING: ThreadSanitizer: data race
Read of size 8 by thread T2:
#0 ceph::common::PerfCounters::set(int, unsigned long) src/common/perf_counters.cc:239
ceph#1 ceph::common::CephContext::_refresh_perf_values() src/common/ceph_context.cc:1081
Previous write of size 8 by main thread:
ceph#1 ceph::common::PerfCountersBuilder::PerfCountersBuilder(...)
ceph#2 ceph::common::CephContext::_enable_perf_counter() src/common/ceph_context.cc:1012
Thread T2 'service' created by main thread
Build the counters first, under _service_thread_lock and before
_service_thread is set, so no caller sees an unstarted thread.
Under TSan, this removes 180 reports from 9 unit tests.
Assisted-by: claude-opus-5-5
Signed-off-by: Dominik Raddatz <[email protected]>
If the re-raised signal does not terminate the process, as under TSan,
reraise_fatal() calls exit(), which runs atexit handlers and static
destructors inside the signal handler while other threads keep running:
WARNING: ThreadSanitizer: signal-unsafe call inside of a signal
ceph#7 Option::~Option() src/common/options.h:15
ceph#14 __static_initialization_and_destruction_0 src/common/options.cc:341
ceph#15 handle_oneshot_fatal_signal src/global/signal_handler.cc:372
ceph#17 ceph::__ceph_assert_fail(...) src/common/assert.cc:102
Under TSan, this removes 50,770 reports from 2 unit tests.
Assisted-by: claude-opus-5-5
Signed-off-by: Dominik Raddatz <[email protected]>
Contributor
Author
Thanks, adopted. |
Contributor
Author
|
jenkins test windows |
Contributor
Author
|
@tchaikov I pushed your start_service_thread suggestion on Nov 11; could you take another look? |
Contributor
|
@Doracly will take a look shortly. |
Contributor
Author
|
@SrinivasaBharath could you add this to a RADOS batch? tchaikov approved it with needs-qa on 11-26. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These commits fix data races and one signal-safety bug that ThreadSanitizer reports in the unit tests.
Each count drops to 0. The _exit() commit is independent of the others. Split from #72460.
Measured with GCC 15.2, Debug, -DWITH_TSAN=ON:
ctest -j4 -R unittest_ -E unittest_erasure_code_shec_allwithTSAN_OPTIONS=second_deadlock_stack=1:history_size=7:report_thread_leaks=0, against main as of 2026-10-05.Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.