Skip to content

cmake: disable ASan exception interception in tests#66875

Open
tchaikov wants to merge 1 commit intoceph:mainfrom
tchaikov:wip-cmake-disableasan-ex-interceptor
Open

cmake: disable ASan exception interception in tests#66875
tchaikov wants to merge 1 commit intoceph:mainfrom
tchaikov:wip-cmake-disableasan-ex-interceptor

Conversation

@tchaikov
Copy link
Contributor

Fix ASan CHECK failure when exceptions are thrown during early initialization, particularly in Python bindings that load Ceph shared libraries.

ASan reported the following error:

  AddressSanitizer: CHECK failed: asan_interceptors.cpp:335
  "((__interception::real___cxa_throw)) != (0)" (0x0, 0x0)
    #0 CheckUnwind asan_rtl.cpp:69
    #1 CheckFailed sanitizer_termination.cpp:86
    #2 __interceptor___cxa_throw asan_interceptors.cpp:335
    #3 boost::throw_exception<boost::bad_lexical_cast>
    #4 boost::conversion::detail::throw_bad_cast
    #5 boost::lexical_cast<unsigned long, std::string>
    #6 librbd::rbd_features_from_string /ceph/src/librbd/Features.cc:67
    #7 get_rbd_options()::$_2::operator() rbd_options.cc:44
    #8 Option::pre_validate /ceph/src/common/options.cc:94
    #9 md_config_t::md_config_t /ceph/src/common/config.cc:208
    #10 CephContext::CephContext /ceph/src/common/ceph_context.cc:730
    #11 rados_create_cct /ceph/src/librados/librados_c.cc:120
    #12 Python rados module initialization

Root cause: When Python loads the Ceph shared library (e.g., rados.so), CephContext initialization validates configuration options. The RBD default features option validator calls rbd_features_from_string(), which uses boost::lexical_cast to parse the feature string. When the string is not numeric (e.g., "layering,exclusive-lock,..."), lexical_cast throws boost::bad_lexical_cast.

This exception is properly caught and handled in the code. However, ASan's exception interceptor (__cxa_throw) may not be fully initialized when exceptions are thrown during early library initialization, causing a CHECK failure.

Why qa/asan.supp is not sufficient:
The existing suppression in qa/asan.supp for __interceptor___cxa_throw only suppresses ASan reports about the interceptor. It does NOT prevent CHECK failures in ASan's runtime itself. CHECK failures are assertions that terminate the program immediately, before any suppression mechanism can be applied. The CHECK fails because real___cxa_throw is NULL (not yet initialized), which is a precondition violation in ASan's interceptor code.

Suppressions work by filtering ASan's output after an issue is detected, but they cannot prevent internal CHECK failures in ASan's initialization logic.

Solution: Disable ASan's C++ exception interception by adding intercept_cxx_exceptions=0 to ASAN_OPTIONS. This prevents ASan from intercepting exception throws/catches, avoiding the initialization order issue. Exception handling still works correctly; we just lose ASan's ability to detect exception-related memory issues.

This is a known limitation when using ASan with code that throws exceptions during static/early initialization, particularly in shared libraries loaded by interpreters like Python.

Note: This does not hide real bugs - the exception is properly caught and handled. We're only disabling ASan's interception mechanism to avoid the initialization order problem.

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 x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

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)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

Fix ASan CHECK failure when exceptions are thrown during early
initialization, particularly in Python bindings that load Ceph
shared libraries.

ASan reported the following error:

  AddressSanitizer: CHECK failed: asan_interceptors.cpp:335
  "((__interception::real___cxa_throw)) != (0)" (0x0, 0x0)
    #0 CheckUnwind asan_rtl.cpp:69
    #1 CheckFailed sanitizer_termination.cpp:86
    #2 __interceptor___cxa_throw asan_interceptors.cpp:335
    #3 boost::throw_exception<boost::bad_lexical_cast>
    #4 boost::conversion::detail::throw_bad_cast
    #5 boost::lexical_cast<unsigned long, std::string>
    #6 librbd::rbd_features_from_string /ceph/src/librbd/Features.cc:67
    #7 get_rbd_options()::$_2::operator() rbd_options.cc:44
    #8 Option::pre_validate /ceph/src/common/options.cc:94
    #9 md_config_t::md_config_t /ceph/src/common/config.cc:208
    #10 CephContext::CephContext /ceph/src/common/ceph_context.cc:730
    #11 rados_create_cct /ceph/src/librados/librados_c.cc:120
    #12 Python rados module initialization

Root cause: When Python loads the Ceph shared library (e.g., rados.so),
CephContext initialization validates configuration options. The RBD
default features option validator calls rbd_features_from_string(),
which uses boost::lexical_cast to parse the feature string. When the
string is not numeric (e.g., "layering,exclusive-lock,..."), lexical_cast
throws boost::bad_lexical_cast.

This exception is properly caught and handled in the code. However, ASan's
exception interceptor (__cxa_throw) may not be fully initialized when
exceptions are thrown during early library initialization, causing a CHECK
failure.

Why qa/asan.supp is not sufficient:
The existing suppression in qa/asan.supp for __interceptor___cxa_throw
only suppresses ASan *reports* about the interceptor. It does NOT prevent
CHECK failures in ASan's runtime itself. CHECK failures are assertions
that terminate the program immediately, before any suppression mechanism
can be applied. The CHECK fails because real___cxa_throw is NULL (not yet
initialized), which is a precondition violation in ASan's interceptor code.

Suppressions work by filtering ASan's output after an issue is detected,
but they cannot prevent internal CHECK failures in ASan's initialization
logic.

Solution: Disable ASan's C++ exception interception by adding
intercept_cxx_exceptions=0 to ASAN_OPTIONS. This prevents ASan from
intercepting exception throws/catches, avoiding the initialization order
issue. Exception handling still works correctly; we just lose ASan's
ability to detect exception-related memory issues.

This is a known limitation when using ASan with code that throws
exceptions during static/early initialization, particularly in shared
libraries loaded by interpreters like Python.

Note: This does not hide real bugs - the exception is properly caught
and handled. We're only disabling ASan's interception mechanism to avoid
the initialization order problem.

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
@tchaikov
Copy link
Contributor Author

jenkins test windows

@tchaikov tchaikov requested a review from Matan-B February 9, 2026 02:41
@tchaikov
Copy link
Contributor Author

tchaikov commented Feb 9, 2026

@Matan-B since you updated the suppression rules in #66994 as well, could you help review this change?

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.

1 participant