Skip to content

Call __lsan_do_leak_check before _exit in safeExit to fix LSan false positives - #98355

Merged
alexey-milovidov merged 4 commits into
masterfrom
fix-lsan-safe-exit
Mar 2, 2026
Merged

alexey-milovidov merged 4 commits into
masterfrom
fix-lsan-safe-exit

Conversation

@alexey-milovidov

Copy link
Copy Markdown
Member

Summary

  • Call __lsan_do_leak_check in safeExit before _exit when ADDRESS_SANITIZER is defined
  • This runs the leak check while all memory is still reachable through global pointers, then disables the subsequent at-exit check
  • Prevents false positives from libraries whose cleanup runs in atexit/static destructors (e.g., OPENSSL_cleanup) which are skipped by _exit
  • Remove the per-library OpenSSLInitializer::cleanup calls from Server.cpp and Keeper.cpp added in Call OpenSSL cleanup before safeExit to fix LeakSanitizer false positives #98296, since this approach handles the problem generically

Supersedes #98296 (reverted in #98354).
#98354

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix LeakSanitizer false positives on forced server shutdown by calling __lsan_do_leak_check before _exit.

🤖 Generated with Claude Code

…anitizer false positives

`safeExit` calls `_exit`, which bypasses static destructors and atexit
handlers. ASan intercepts `_exit` and runs LSan, which then reports
memory from libraries (e.g., OpenSSL global state) as leaked because
their cleanup routines never ran.

By calling `__lsan_do_leak_check` before `_exit`, the leak check runs
while all memory is still reachable through global pointers, and the
subsequent at-exit check is disabled. This prevents false positives
without requiring per-library cleanup calls.

Supersedes #98296 (reverted in #98354).
#98354

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Feb 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [08452a4]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Feb 28, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Mar 2, 2026
@alexey-milovidov alexey-milovidov self-assigned this Mar 2, 2026
Merged via the queue into master with commit 9b1ffa8 Mar 2, 2026
144 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-lsan-safe-exit branch March 2, 2026 03:32
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants