Type:
Bug
Priority:
Critical
Resolution:
Fixed
Affects Version/s:
10.5 , 10.6 , 10.11 , 11.0(EOL) , 11.1(EOL) , 11.2(EOL)
The regression MDEV-33972 was only caught in a rather obscure way: a bit of an unrelated pointer was being cleared, because some code was dereferencing an invalid iterator.
It turns out that there is a simple way to enable debugging for the iterators defined in the GNU libstdc++ :
diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt
index 5f01f8c9704..bccf81a6b5b 100644
--- a/storage/innobase/CMakeLists.txt
+++ b/storage/innobase/CMakeLists.txt
@@ -78,7 +78,7 @@ ADD_FEATURE_INFO(INNODB_ROOT_GUESS WITH_INNODB_ROOT_GUESS
OPTION(WITH_INNODB_EXTRA_DEBUG "Enable extra InnoDB debug checks" OFF)
IF(WITH_INNODB_EXTRA_DEBUG)
- ADD_DEFINITIONS(-DUNIV_ZIP_DEBUG -DLOG_LATCH_DEBUG)
+ ADD_DEFINITIONS(-DUNIV_ZIP_DEBUG -DLOG_LATCH_DEBUG -D_GLIBCXX_DEBUG)
ENDIF()
ADD_FEATURE_INFO(INNODB_EXTRA_DEBUG WITH_INNODB_EXTRA_DEBUG "Extra InnoDB debug checks")
However, this has no effect on the clang libc++ , which is a prerequisite for MemorySanitizer builds (MDEV-20377 ). There used to be -D_LIBCPP_DEBUG , but it has been split into multiple flags:
diff --git a/libcxx/include/__assert b/libcxx/include/__assert
index d94a657aac50..e20ee50b127c 100644
--- a/libcxx/include/__assert
+++ b/libcxx/include/__assert
@@ -17,11 +17,6 @@
# pragma GCC system_header
#endif
-// TODO: Remove in LLVM 17.
-#if defined(_LIBCPP_DEBUG)
-# error "Defining _LIBCPP_DEBUG is not supported anymore. Please use _LIBCPP_ENABLE_DEBUG_MODE instead."
-#endif
-
// Automatically enable assertions when the debug mode is enabled.
#if defined(_LIBCPP_ENABLE_DEBUG_MODE)
# ifndef _LIBCPP_ENABLE_ASSERTIONS
I did not have any luck with that flag either. The libstdc++ flag works:
10.11 f0d0ddc992703f2d31d8ad0d963f127a8b4d05e9
/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/debug/safe_iterator.h:372:
In function:
pointer
gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<dict_table_t
*const, trx_mod_table_time_t>>, std::map<dict_table_t *,
trx_mod_table_time_t, std::less<dict_table_t *>,
ut_allocator<std::pair<dict_table_t *const, trx_mod_table_time_t>>>,
std::forward_iterator_tag>::operator->() const [_Iterator =
std::_Rb_tree_iterator<std::pair<dict_table_t *const,
trx_mod_table_time_t>>, _Sequence = std::map<dict_table_t *,
trx_mod_table_time_t, std::less<dict_table_t *>,
ut_allocator<std::pair<dict_table_t *const, trx_mod_table_time_t>>>,
_Category = std::forward_iterator_tag]
Error: attempt to dereference a past-the-end iterator.
Objects involved in the operation:
iterator "this" @ 0x7fb892ffd7a8 {
type = std::_Rb_tree_iterator<std::pair<dict_table_t* const, trx_mod_table_time_t> > (mutable iterator);
state = past-the-end;
references sequence with type 'std::debug::map<dict_table_t*, trx_mod_table_time_t, std::less<dict_table_t*>, ut_allocator<std::pair<dict_table_t* const, trx_mod_table_time_t>, true> >' @ 0x7fb8918016b0
}
240423 14:07:36 [ERROR] mysqld got signal 6 ;
I would prefer something like the following to cover all use of iterators:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6477c4042d6..e0d73899632 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -277,7 +277,14 @@ ENDIF()
# Always enable debug sync for debug builds.
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC")
-
+
+IF(MSVC)
+ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_ITERATOR_DEBUG_LEVEL=1")
+ELSE()
+ # Enable extra checks on GNU libstdc++ iterators
+ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
+ENDIF()
+
OPTION(ENABLE_GCOV "Enable gcov (debug, Linux builds only)" OFF)
IF (ENABLE_GCOV)
MY_CHECK_AND_SET_COMPILER_FLAG("-DHAVE_gcov -fprofile-arcs -ftest-coverage -lgcov" DEBUG)
Unfortunately it would cause link-time failures like this:
10.11 f0d0ddc992703f2d31d8ad0d963f127a8b4d05e9
ld.lld: error: undefined symbol: wsrep::client_state::enter_toi_local(std::__debug::vector<wsrep::key, std::allocator<wsrep::key>> const&, wsrep::const_buffer const&, std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l>>>)
>>> referenced by wsrep_mysqld.cc:2794 (/mariadb/10.11/sql/wsrep_mysqld.cc:2794)
>>> wsrep_mysqld.cc.o:(wsrep_TOI_begin(THD*, char const*, char const*, TABLE_LIST const*, Alter_info const*, std::__debug::vector<wsrep::key, std::allocator<wsrep::key>> const*, HA_CREATE_INFO const*)) in archive sql/libwsrep.a
I see that wsrep-lib/CMakeLists.txt is doing something to the project-wide CMAKE_CXX_FLAGS ; this might be the reason.
relates to
MDEV-33972
Memory corruption in innodb.insert_into_empty
Closed
{"report":{"fcp":739.1000001430511,"ttfb":151.70000004768372,"pageVisibility":"visible","entityId":128871,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"2059e576-df71-423b-ae13-790d05b4ab99","navigationType":0,"readyForUser":831.1000001430511,"redirectCount":0,"resourceLoadedEnd":861.6000001430511,"resourceLoadedStart":157.40000009536743,"resourceTiming":[{"duration":122.79999995231628,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":157.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":157.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":280.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":122.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":157.70000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":157.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":280.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":131.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":157.79999995231628,"connectEnd":157.79999995231628,"connectStart":157.79999995231628,"domainLookupEnd":157.79999995231628,"domainLookupStart":157.79999995231628,"fetchStart":157.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":157.79999995231628,"responseEnd":289.5,"responseStart":289.5,"secureConnectionStart":157.79999995231628},{"duration":220.60000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":158,"connectEnd":158,"connectStart":158,"domainLookupEnd":158,"domainLookupStart":158,"fetchStart":158,"redirectEnd":0,"redirectStart":0,"requestStart":158,"responseEnd":378.60000014305115,"responseStart":378.60000014305115,"secureConnectionStart":158},{"duration":224.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":158.10000014305115,"connectEnd":158.10000014305115,"connectStart":158.10000014305115,"domainLookupEnd":158.10000014305115,"domainLookupStart":158.10000014305115,"fetchStart":158.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":158.10000014305115,"responseEnd":382.2999999523163,"responseStart":382.2999999523163,"secureConnectionStart":158.10000014305115},{"duration":224.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":158.20000004768372,"connectEnd":158.20000004768372,"connectStart":158.20000004768372,"domainLookupEnd":158.20000004768372,"domainLookupStart":158.20000004768372,"fetchStart":158.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":158.20000004768372,"responseEnd":382.7999999523163,"responseStart":382.7999999523163,"secureConnectionStart":158.20000004768372},{"duration":224.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":158.29999995231628,"connectEnd":158.29999995231628,"connectStart":158.29999995231628,"domainLookupEnd":158.29999995231628,"domainLookupStart":158.29999995231628,"fetchStart":158.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":158.29999995231628,"responseEnd":383.2000000476837,"responseStart":383.2000000476837,"secureConnectionStart":158.29999995231628},{"duration":225.79999995231628,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":158.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":158.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":384.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":225.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":158.5,"connectEnd":158.5,"connectStart":158.5,"domainLookupEnd":158.5,"domainLookupStart":158.5,"fetchStart":158.5,"redirectEnd":0,"redirectStart":0,"requestStart":158.5,"responseEnd":384.2000000476837,"responseStart":384.2000000476837,"secureConnectionStart":158.5},{"duration":226.19999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":158.60000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":158.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":384.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":226,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":158.79999995231628,"connectEnd":158.79999995231628,"connectStart":158.79999995231628,"domainLookupEnd":158.79999995231628,"domainLookupStart":158.79999995231628,"fetchStart":158.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":158.79999995231628,"responseEnd":384.7999999523163,"responseStart":384.7999999523163,"secureConnectionStart":158.79999995231628},{"duration":337.2000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":159.5,"connectEnd":159.5,"connectStart":159.5,"domainLookupEnd":159.5,"domainLookupStart":159.5,"fetchStart":159.5,"redirectEnd":0,"redirectStart":0,"requestStart":159.5,"responseEnd":496.7000000476837,"responseStart":496.7000000476837,"secureConnectionStart":159.5},{"duration":652.2999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":159.60000014305115,"connectEnd":159.60000014305115,"connectStart":159.60000014305115,"domainLookupEnd":159.60000014305115,"domainLookupStart":159.60000014305115,"fetchStart":159.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":159.60000014305115,"responseEnd":811.9000000953674,"responseStart":811.9000000953674,"secureConnectionStart":159.60000014305115},{"duration":54.39999985694885,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":443.60000014305115,"connectEnd":443.60000014305115,"connectStart":443.60000014305115,"domainLookupEnd":443.60000014305115,"domainLookupStart":443.60000014305115,"fetchStart":443.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":443.60000014305115,"responseEnd":498,"responseStart":498,"secureConnectionStart":443.60000014305115},{"duration":201.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":660.1000001430511,"connectEnd":660.1000001430511,"connectStart":660.1000001430511,"domainLookupEnd":660.1000001430511,"domainLookupStart":660.1000001430511,"fetchStart":660.1000001430511,"redirectEnd":0,"redirectStart":0,"requestStart":660.1000001430511,"responseEnd":861.6000001430511,"responseStart":861.6000001430511,"secureConnectionStart":660.1000001430511},{"duration":129.79999995231628,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":732.4000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":732.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":862.2000000476837,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":10,"responseStart":151,"responseEnd":155,"domLoading":155,"domInteractive":900,"domContentLoadedEventStart":900,"domContentLoadedEventEnd":951,"domComplete":1542,"loadEventStart":1542,"loadEventEnd":1542,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":876.7000000476837},{"name":"bigPipe.sidebar-id.end","time":877.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":877.7000000476837},{"name":"bigPipe.activity-panel-pipe-id.end","time":880.2999999523163},{"name":"activityTabFullyLoaded","time":958.2999999523163}],"measures":[],"correlationId":"d8352c1e9e2711","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":74,"dbReadsTimeInMs":12,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}