Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gdb/dist/gdb/nat Limit the switch_to_thread() ...



details:   https://anonhg.NetBSD.org/src/rev/f81be6197f41
branches:  trunk
changeset: 940688:f81be6197f41
user:      kamil <kamil%NetBSD.org@localhost>
date:      Wed Oct 14 14:02:43 2020 +0000

description:
Limit the switch_to_thread() calls in startup_inferior()

Do not jump over the threads during the startup unless we encounter
TARGET_WAITKIND_STOPPED with SIGTRAP or TARGET_WAITKIND_EXECD.

Otherwise whenever a startup-with-shell processes signals on the
startup stage, it might indicate to switch to a non-existing
thread or a special-thread number (target lwp=0 on NetBSD means
that a signal was directed to all threads within a process).

This caused a crash with tcsh on NetBSD, where the tcsh shell
runs startup detection of the hostname. This action involves
spwaning a new process through fork.

GDB crashes this way:
$ SHELL=tcsh /usr/bin/gdb echo
(gdb) r
Starting program: /bin/echo
/usr/src/external/gpl3/gdb/lib/libgdb/../../dist/gdb/thread.c:1309:
internal-error: void switch_to_thread(thread_info*):
Assertion `thr != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

This patch has been submitted upstream for review:

https://sourceware.org/pipermail/gdb-patches/2020-October/172558.html

diffstat:

 external/gpl3/gdb/dist/gdb/nat/fork-inferior.c |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (22 lines):

diff -r df16b64c08da -r f81be6197f41 external/gpl3/gdb/dist/gdb/nat/fork-inferior.c
--- a/external/gpl3/gdb/dist/gdb/nat/fork-inferior.c    Wed Oct 14 13:43:56 2020 +0000
+++ b/external/gpl3/gdb/dist/gdb/nat/fork-inferior.c    Wed Oct 14 14:02:43 2020 +0000
@@ -503,7 +503,6 @@
          case TARGET_WAITKIND_SYSCALL_ENTRY:
          case TARGET_WAITKIND_SYSCALL_RETURN:
            /* Ignore gracefully during startup of the inferior.  */
-           switch_to_thread (proc_target, event_ptid);
            break;
 
          case TARGET_WAITKIND_SIGNALLED:
@@ -536,7 +535,9 @@
 
          case TARGET_WAITKIND_STOPPED:
            resume_signal = ws.value.sig;
-           switch_to_thread (proc_target, event_ptid);
+           /* Ignore gracefully the !TRAP signals intercepted from the shell.  */
+           if (resume_signal == GDB_SIGNAL_TRAP)
+             switch_to_thread (proc_target, event_ptid);
            break;
        }
 



Home | Main Index | Thread Index | Old Index