Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-33974 Enable GNU libstdc++ debugging #3219

Merged
merged 1 commit into from
Apr 25, 2024
Merged

MDEV-33974 Enable GNU libstdc++ debugging #3219

merged 1 commit into from
Apr 25, 2024

Conversation

dr-m
Copy link
Contributor

@dr-m dr-m commented Apr 23, 2024

  • The Jira issue number for this PR is: MDEV-33974

Description

On GCC 10 or later, let us enable _GLIBCXX_DEBUG as well as _GLIBCXX_ASSERTIONS which have an impact on the GNU libstdc++. This should catch bugs like the one that commit 455a15f fixed.

For the clang libc++ before clang-15 there was _LIBCPP_DEBUG, but according to llvm/llvm-project@f3966ea and llvm/llvm-project@13ea134 and llvm/llvm-project@ff573a4 it looks like that for proper results, a specially built debug version of libc++ would have to be used in order to enable equivalent checks.

Release Notes

Debug builds will try to catch some C++ API misuse in GNU libstdc++ when using GCC 10 or later.

How can this PR be tested?

./mtr innodb.insert_into_empty is expected to crash as long as the commit 455a15f is not included. However, for some reason it did not crash on our CI. I tested 35aa7d6 in the amd64-ubuntu-2004-debug environment with an additional bug injection:

--- mariadb-10.11.8/storage/innobase/row/row0merge.cc	2024-04-23 13:33:06.000000000 +0000
+++ mariadb-10.11.8/storage/innobase/row/row0merge.cc.buggy	2024-04-24 10:04:06.755847419 +0000
@@ -5379,8 +5379,8 @@
       bulk_rollback_low();
       return err;
     }
-    it->second.end_bulk_insert();
   }
+    it->second.end_bulk_insert();
   return DB_SUCCESS;
 }
 

This would fail during the server bootstrap:

/usr/include/c++/10/debug/safe_iterator.h:314:
In function:
    __gnu_debug::_Safe_iterator<_Iterator, _Sequence, _Category>::pointer 
    __gnu_debug::_Safe_iterator<_Iterator, _Sequence, 
    _Category>::operator->() const [with _Iterator = 
    std::_Rb_tree_iterator<std::pair<dict_table_t* const, 
    trx_mod_table_time_t> >; _Sequence = 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> > >; 
    _Category = std::forward_iterator_tag; 
    __gnu_debug::_Safe_iterator<_Iterator, _Sequence, _Category>::pointer = 
    std::pair<dict_table_t* const, trx_mod_table_time_t>*]

Error: attempt to dereference a past-the-end iterator.

Objects involved in the operation:
    iterator "this" @ 0x0x7ffdb1ef83f0 {
      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> >' @ 0x0x7f1508f6e6b0
    }

Basing the PR against the correct MariaDB version

  • This is a new feature and the PR is based against the latest MariaDB development branch.
  • This is a bug fix and the PR is based against the earliest maintained branch in which the bug can be reproduced.

This has been tested on 10.11, but the final version will target the 10.5 branch and not the earliest maintained branch 10.4 because it is so close to end-of-life.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

@dr-m dr-m self-assigned this Apr 23, 2024
@CLAassistant
Copy link

CLAassistant commented Apr 23, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
@dr-m dr-m force-pushed the 10.11-MDEV-33974 branch 2 times, most recently from 35aa7d6 to 11340bc Compare April 24, 2024 10:34
@dr-m dr-m changed the title MDEV-33974 STL iterator debugging is not enabled MDEV-33974 Enable GNU libstdc++ debugging Apr 24, 2024
@dr-m dr-m changed the base branch from 10.11 to 10.5 April 24, 2024 10:37
@dr-m dr-m requested a review from vuvova April 24, 2024 10:38
@dr-m dr-m marked this pull request as ready for review April 24, 2024 10:38
Starting with GCC 10, let us enable _GLIBCXX_DEBUG as well as
_GLIBCXX_ASSERTIONS which have an impact on the GNU libstdc++.
On GCC 8, we observed a compilation failure related to some
missing type conversion.

Even though clang on GNU/Linux would default to using libstdc++
and enabling the debugging seems to work with clang-18, we will
not enable this on clang, in case it would lead to compilation
errors.

For the clang libc++ before clang-15 there was _LIBCPP_DEBUG,
but according to
llvm/llvm-project@f3966ea and
llvm/llvm-project@13ea134 and
llvm/llvm-project@ff573a4 it
looks like that for proper results, a specially built debug version
of libc++ would have to be used in order to enable equivalent checks.

This should help catch bugs like the one that
commit 455a15f fixed.

Reviewed by: Sergei Golubchik
@dr-m dr-m removed the request for review from vuvova April 25, 2024 08:40
@dr-m dr-m merged commit a1c1f50 into 10.5 Apr 25, 2024
13 of 16 checks passed
@dr-m dr-m deleted the 10.11-MDEV-33974 branch April 25, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants