[MDEV-26949] --debug-gdb installs redundant signal handlers Created: 2021-11-01  Updated: 2021-11-01  Resolved: 2021-11-01

Status: Closed
Project: MariaDB Server
Component/s: Server, Tests
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7
Fix Version/s: 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6, 10.7.2

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: affects-tests, rr-profile-analyzed


 Description   

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]


Generated at Thu Feb 08 09:49:10 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.