$ make check TESTS="gdb.base/quit-live.exp" RUNTESTFLAGS="--target_board=native-gdbserver" (gdb) continue Continuing. Breakpoint 1, main () at /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/quit-live.c:23 23 int secs = 30; (gdb) Executing on host: kill -TERM 1423439 (timeout = 300) builtin_spawn -ignore SIGHUP kill -TERM 1423439 SIGTERM /home/smarchi/src/binutils-gdb/gdb/exceptions.c:100: internal-error: Bad switch. A problem internal to GDB has been detected, further debugging may prove unreliable. ----- Backtrace ----- FAIL: gdb.base/quit-live.exp: appear_how=run: extra_inferior=0: quit_how=sigterm: quit with SIGTERM (GDB internal error) Resyncing due to internal error. 0x5576e43849ed gdb_internal_backtrace_1 /home/smarchi/src/binutils-gdb/gdb/bt-utils.c:122 0x5576e4384ee3 gdb_internal_backtrace() /home/smarchi/src/binutils-gdb/gdb/bt-utils.c:168 0x5576e6e86f10 internal_vproblem /home/smarchi/src/binutils-gdb/gdb/utils.c:401 0x5576e6e87c32 internal_verror(char const*, int, char const*, __va_list_tag*) /home/smarchi/src/binutils-gdb/gdb/utils.c:481 0x5576e836c2d9 internal_error_loc(char const*, int, char const*, ...) /home/smarchi/src/binutils-gdb/gdbsupport/errors.cc:58 0x5576e4ff5780 print_exception /home/smarchi/src/binutils-gdb/gdb/exceptions.c:100 0x5576e4ff5930 exception_print(ui_file*, gdb_exception const&) /home/smarchi/src/binutils-gdb/gdb/exceptions.c:110 0x5576e6a896dd quit_force(int*, int) /home/smarchi/src/binutils-gdb/gdb/top.c:1849 0x5576e4fedf0c async_sigterm_handler /home/smarchi/src/binutils-gdb/gdb/event-top.c:1208 0x5576e402c0e6 invoke_async_signal_handlers() /home/smarchi/src/binutils-gdb/gdb/async-event.c:233 0x5576e836cc2c gdb_do_one_event(int) /home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:199 0x5576e587b90a start_event_loop /home/smarchi/src/binutils-gdb/gdb/main.c:411 0x5576e587bdb9 captured_command_loop /home/smarchi/src/binutils-gdb/gdb/main.c:475 0x5576e5881123 captured_main /home/smarchi/src/binutils-gdb/gdb/main.c:1318 0x5576e5881270 gdb_main(captured_main_args*) /home/smarchi/src/binutils-gdb/gdb/main.c:1337 0x5576e3a6f60c main /home/smarchi/src/binutils-gdb/gdb/gdb.c:32
Started with: Handle gdb SIGTERM by throwing / catching gdb_exception_force_quit https://inbox.sourceware.org/gdb-patches/20230222234613.29662-3-kevinb@redhat.com/
It appears that I forgot to add a case for RETURN_FORCED_QUIT. I'll work on a fix...
The master branch has been updated by Kevin Buettner <kevinb@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3b431a3c9071d3e654e66a461e152c6bf8386096 commit 3b431a3c9071d3e654e66a461e152c6bf8386096 Author: Kevin Buettner <kevinb@redhat.com> Date: Fri Mar 10 15:27:43 2023 -0700 PR gdb/30219: Clear sync_quit_force_run in quit_force PR 30219 shows an internal error due to a "Bad switch" in print_exception() in gdb/exceptions.c. The switch in question contains cases for RETURN_QUIT and RETURN_ERROR, but is missing a case for the recently added RETURN_FORCED_QUIT. This commit adds that case. Making the above change allows the errant test case to pass, but does not fix the underlying problem, which I'll describe shortly. Even though the addition of a case for RETURN_FORCED_QUIT isn't the actual fix, I still think it's important to add this case so that other situations which lead to print_exeption() being called won't generate that "Bad switch" internal error. In order to understand the underlying problem, please examine this portion of the backtrace from the bug report: 0x5576e4ff5780 print_exception /home/smarchi/src/binutils-gdb/gdb/exceptions.c:100 0x5576e4ff5930 exception_print(ui_file*, gdb_exception const&) /home/smarchi/src/binutils-gdb/gdb/exceptions.c:110 0x5576e6a896dd quit_force(int*, int) /home/smarchi/src/binutils-gdb/gdb/top.c:1849 The real problem is in quit_force; here's the try/catch which eventually leads to the internal error: /* Get out of tfind mode, and kill or detach all inferiors. */ try { disconnect_tracing (); for (inferior *inf : all_inferiors ()) kill_or_detach (inf, from_tty); } catch (const gdb_exception &ex) { exception_print (gdb_stderr, ex); } While running the calls in the try-block, a QUIT check is being performed. This check finds that sync_quit_force_run is (still) set, causing a gdb_exception_forced_quit to be thrown. The exception gdb_exception_forced_quit is derived from gdb_exception, causing exception_print to be called. As shown by the backtrace, print_exception is then called, leading to the internal error. The actual fix, also implemented by this commit, is to clear sync_quit_force_run along with the quit flag. This will allow the various cleanup code, called by quit_force, to run without triggering a gdb_exception_forced_quit. (Though, if another SIGTERM is sent to the gdb process, these flags will be set again and a QUIT check in the cleanup code will detect it and throw the exception.) Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30219 Approved-By: Simon Marchi <simon.marchi@efficios.com>
Fixed now.