Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-26949

--debug-gdb installs redundant signal handlers




      There is a server startup option --gdb a.k.a. --debug-gdb that requests signals to be set for more convenient debugging. Most notably, SIGINT (ctrl-c) will not be ignored, and you will be able to interrupt the execution of the server while GDB is attached to it.

      When we are debugging, the signal handlers that would normally display a terse stack trace (of the current thread only, with no values of function parameters, and often not with correct names of symbols) are useless.

      When we are debugging with rr, the signal handlers may interfere with a SIGKILL that could be sent to the process by the environment, and ruin the rr replay trace, due to a Linux kernel bug.

      To be able to diagnose bugs in kill+restart tests, we may really need both a trace before the SIGKILL and a trace of the failure after a subsequent server startup. So, we’d better avoid hitting the problem by simply not installing those signal handlers:

      diff --git a/mysql-test/lib/My/Debugger.pm b/mysql-test/lib/My/Debugger.pm
      index a115da92e7e..4235abd7887 100644
      --- a/mysql-test/lib/My/Debugger.pm
      +++ b/mysql-test/lib/My/Debugger.pm
      @@ -150,7 +150,8 @@ sub do_args($$$$$) {
         my %vars = (
           vardir => $::opt_vardir,
           exe => $$exe,
      -    args => join(' ', map { quote_from_mtr $_ } @$$args, '--loose-gdb'),
      +    args => join(' ', map { quote_from_mtr $_ } @$$args,
      +                 '--loose-debug-gdb', '--loose-skip-stack-trace'),
           input => $input,
           script => "$::opt_vardir/tmp/${k}init.$type",
           log => "$::opt_vardir/log/$type.$k",
      diff --git a/sql/mysqld.cc b/sql/mysqld.cc
      index f7717e188ee..a8af660118c 100644
      --- a/sql/mysqld.cc
      +++ b/sql/mysqld.cc
      @@ -8521,7 +8521,6 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
           /* Allow break with SIGINT, no core or stack trace */
           test_flags|= TEST_SIGINT;
      -    opt_stack_trace= 1;
           test_flags&= ~TEST_CORE_ON_SIGNAL;
         /* Set global MyISAM variables from delay_key_write_options */

      With this patch, the signal handler (with the stack trace output) will still be used in normal ./mtr invocations. I tested it with a test case of MDEV-25440:

      10.2 059797ed44007fe954cf47f6f09db78e60df16fd

      Version: '10.2.41-MariaDB-debug-log'  socket: '/dev/shm/10.2o/mysql-test/var/tmp/mysqld.1.sock'  port: 16000  Source distribution
      mysqld: /mariadb/10.2o/storage/innobase/btr/btr0bulk.cc:199: void PageBulk::insert(const rec_t*, rec_offs*): Assertion `cmp_rec_rec(rec, old_rec, offsets, old_offsets, m_index) > 0' failed.
      211101  9:23:52 [ERROR] mysqld got signal 6 ;
      include/rem0rec.ic:474(PageBulk::insert(unsigned char const*, unsigned short*))[0x561a07491d51]
      btr/btr0bulk.cc:980(BtrBulk::insert(dtuple_t*, unsigned long))[0x561a07497f29]




            marko Marko Mäkelä
            marko Marko Mäkelä
            0 Vote for this issue
            1 Start watching this issue



                Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.