cmake: disable ASan exception interception in tests#66875
Open
cmake: disable ASan exception interception in tests#66875
Conversation
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>
14 tasks
Contributor
Author
|
jenkins test windows |
Contributor
Author
14 tasks
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.
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:
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 usesboost::lexical_castto parse the feature string. When the string is not numeric (e.g., "layering,exclusive-lock,..."), lexical_cast throwsboost::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.suppis not sufficient:The existing suppression in qa/asan.supp for
__interceptor___cxa_throwonly 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
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.