Skip to content

log: load the test prefix hook atomically and only once - #72166

Merged
rzarzynski merged 1 commit into
ceph:mainfrom
aainscow:wip-80565-log-prefix-hook-race
Oct 15, 2026
Merged

rzarzynski merged 1 commit into
ceph:mainfrom
aainscow:wip-80565-log-prefix-hook-race

Conversation

@aainscow

@aainscow aainscow commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Log::_flush() runs on the log thread and did prefix_hook ? prefix_hook() : nullptr on a plain global. PGBackendTestFixture sets the hook in SetUp() and clears it in TearDown() on the gtest thread. In a Debug build the global is read twice, and if TearDown() clears it between the check and the call, the log thread calls address 0. That is the SIGSEGV in thread log with a two-frame backtrace seen in unittest_backend_basics.

This makes the hook a std::atomic and reads it once into a local before testing and calling it.

Reproducer (not included): add a usleep(2000) between the check and the call, then run unittest_backend_basics --gtest_filter='BackendSizes/TestBackendBasics.*/Replicated_*'. It crashes within a few tests with the same signature as CI. With this fix and the same sleep after the single load, 3 repeats run without a crash. The full unittest_backend_basics passes (888 tests).

While this is only used by a single test harness, out of paranoia I am running it through a QA batch, as its not that urgent.

Fixes: https://tracker.ceph.com/issues/80565

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

🤖 Generated with Claude Code

Log::_flush() runs on the log thread and did

  prefix_hook ? prefix_hook() : nullptr

on a plain global. PGBackendTestFixture sets the hook in SetUp() and
clears it in TearDown() on the gtest thread, so the hook changes while
the log thread is flushing. In a Debug build the global is read twice,
and if TearDown() clears it between the check and the call, the log
thread calls address 0. This is the SIGSEGV in thread "log" with a
two-frame backtrace seen in unittest_backend_basics.

Make the hook a std::atomic and read it once into a local before
testing and calling it.

The crash was reproduced by adding a sleep between the check and the
call and running the Replicated TestBackendBasics cases, which set up
and tear down quickly. It crashes within a few tests, and the same
sleep placed after the single load does not crash.

Fixes: https://tracker.ceph.com/issues/80565
Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
@aainscow
aainscow force-pushed the wip-80565-log-prefix-hook-race branch from 4f2d630 to 1b1c682 Compare September 29, 2026 10:45
@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath10-testing-20261012.232418-main.

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@rzarzynski
rzarzynski merged commit a469202 into ceph:main Oct 15, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants