public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30926] New: FAIL: gdb.threads/detach-step-over.exp: breakpoint-condition-evaluation=host: target-non-stop=on: non-stop=on: displaced=off: test_detach_command: iter 921: attach (GDB internal error)
@ 2023-10-01  3:53 simark at simark dot ca
  0 siblings, 0 replies; only message in thread
From: simark at simark dot ca @ 2023-10-01  3:53 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30926

            Bug ID: 30926
           Summary: FAIL: gdb.threads/detach-step-over.exp:
                    breakpoint-condition-evaluation=host:
                    target-non-stop=on: non-stop=on: displaced=off:
                    test_detach_command: iter 921: attach (GDB internal
                    error)
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: simark at simark dot ca
  Target Milestone: ---

I often see gdb.threads/detach-step-over.exp failing in my test runs.  I
isolated one of them:

FAIL: gdb.threads/detach-step-over.exp: breakpoint-condition-evaluation=host:
target-non-stop=on: non-stop=on: displaced=off: test_detach_command: iter 921:
attach (GDB internal error)

I made the following changes to make the investigation easier:

~~~
diff --git a/gdb/debug.c b/gdb/debug.c
index ca8fb1072712..d9978974fe6b 100644
--- a/gdb/debug.c
+++ b/gdb/debug.c
@@ -20,6 +20,7 @@
 #include "defs.h"

 #include "gdbsupport/common-debug.h"
+#include "gdbsupport/filestuff.h"

 /* See gdbsupport/common-debug.h.  */

@@ -30,5 +31,15 @@ int debug_print_depth = 0;
 void
 debug_vprintf (const char *fmt, va_list ap)
 {
-  gdb_vprintf (gdb_stdlog, fmt, ap);
+  static gdb_file_up f;
+  static std::unique_ptr<stdio_file> u;
+  if (!f)
+    {
+      f = gdb_fopen_cloexec ("/tmp/log", "w");
+      gdb_assert (f);
+      u = gdb::make_unique<stdio_file> (f.get (), true);
+    }
+
+  gdb_vprintf (u.get(), fmt, ap);
+  u->flush ();
 }
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 4730d2904423..e2f9369b9e3b 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1423,6 +1423,7 @@ struct step_over_info

   /* The thread's global number.  */
   int thread = -1;
+  ptid_t ptid = minus_one_ptid;
 };

 /* The step-over info of the location that is being stepped over.
@@ -1459,12 +1460,13 @@ static struct step_over_info step_over_info;
 static void
 set_step_over_info (const address_space *aspace, CORE_ADDR address,
                    int nonsteppable_watchpoint_p,
-                   int thread)
+                   thread_info *thread)
 {
   step_over_info.aspace = aspace;
   step_over_info.address = address;
   step_over_info.nonsteppable_watchpoint_p = nonsteppable_watchpoint_p;
-  step_over_info.thread = thread;
+  step_over_info.thread = thread ? thread->global_num : -1;
+  step_over_info.ptid = thread ? thread->ptid : minus_one_ptid;
 }

 /* Called when we're not longer stepping over a breakpoint / an
@@ -1478,6 +1480,7 @@ clear_step_over_info (void)
   step_over_info.address = 0;
   step_over_info.nonsteppable_watchpoint_p = 0;
   step_over_info.thread = -1;
+  step_over_info.ptid = minus_one_ptid;
 }

 /* See infrun.h.  */
@@ -2649,7 +2652,7 @@ resume_1 (enum gdb_signal sig)
            stop_all_threads ("displaced stepping falling back on inline
stepping");

          set_step_over_info (regcache->aspace (),
-                             regcache_read_pc (regcache), 0, tp->global_num);
+                             regcache_read_pc (regcache), 0, tp);

          step = maybe_software_singlestep (gdbarch);

@@ -8526,10 +8529,10 @@ keep_going_pass_signal (struct execution_control_state
*ecs)
        {
          set_step_over_info (regcache->aspace (),
                              regcache_read_pc (regcache), remove_wps,
-                             ecs->event_thread->global_num);
+                             ecs->event_thread);
        }
       else if (remove_wps)
-       set_step_over_info (nullptr, 0, remove_wps, -1);
+       set_step_over_info (nullptr, 0, remove_wps, nullptr);

       /* If we now need to do an in-line step-over, we need to stop
         all other threads.  Note this must be done before
diff --git a/gdb/testsuite/gdb.threads/detach-step-over.exp
b/gdb/testsuite/gdb.threads/detach-step-over.exp
index 345c77e2c690..4806e20a5a6f 100644
--- a/gdb/testsuite/gdb.threads/detach-step-over.exp
+++ b/gdb/testsuite/gdb.threads/detach-step-over.exp
@@ -214,7 +214,8 @@ proc_with_prefix test_detach_command {condition_eval
target_non_stop non_stop di
        }
     }

-    set attempts 3
+    set attempts 1000
+    gdb_test "set debug infrun"
     for {set attempt 1} { $attempt <= $attempts } { incr attempt } {
        with_test_prefix "iter $attempt" {
            gdb_test "inferior 1" "Switching to .*"
@@ -377,24 +378,22 @@ gdb_test_multiple $cmd "probe condition-evaluation target
support" {
     }
 }

-foreach_with_prefix breakpoint-condition-evaluation {"host" "target"} {
+foreach_with_prefix breakpoint-condition-evaluation {"host"} {
     if {!$supports_condition_eval_target && ${breakpoint-condition-evaluation}
== "target"} {
        continue
     }

-    foreach_with_prefix target-non-stop {"off" "on"} {
-       foreach_with_prefix non-stop {"off" "on"} {
+    foreach_with_prefix target-non-stop {"on"} {
+       foreach_with_prefix non-stop {"on"} {
            if {${non-stop} && !${target-non-stop}} {
                # "set non-stop" overrides "maint set
                # target-non-stop", no use testing this combination.
                continue
            }

-           foreach_with_prefix displaced {"off" "auto"} {
+           foreach_with_prefix displaced {"off"} {
                test_detach_command ${breakpoint-condition-evaluation} \
                    ${target-non-stop} ${non-stop} ${displaced}
-               test_detach_quit ${breakpoint-condition-evaluation} \
-                   ${target-non-stop} ${non-stop} ${displaced}
            }
        }
     }
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index de22da8d8a8c..ecf0f236585e 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1212,6 +1212,9 @@ proc gdb_test_multiple { command message args } {
     append code {
        -re ".*A problem internal to GDB has been detected" {
            fail "$message (GDB internal error)"
+           # Let us attach to GDB while it's still in the internal error call
stack
+           set ::timeout 888888
+           sleep 1231231
            gdb_internal_error_resync
            set result -1
        }

~~~

The tail end of /tmp/log is:

[infrun] fetch_inferior_event: enter
  [infrun] scoped_disable_commit_resumed: reason=handling event
  [infrun] random_resumed_with_pending_wait_status: Found 9 events, selecting
#6
  [infrun] random_pending_event_thread: Found 4185505.4185515.0.
  [infrun] do_target_wait_1: Using pending wait status status->kind = STOPPED,
sig = GDB_SIGNAL_TRAP for 4185505.4185515.0.
  [infrun] maybe_remove_resumed_with_pending_wait_status: removing from resumed
threads with event list: 4185505.4185515.0
  [infrun] print_target_wait_results: target_wait (-1.0.0 [process -1], status)
=
  [infrun] print_target_wait_results:   4185505.4185515.0 [Thread
0x7ffff44b76c0 (LWP 4185515)],
  [infrun] print_target_wait_results:   status->kind = STOPPED, sig =
GDB_SIGNAL_TRAP
  [infrun] handle_inferior_event: status->kind = STOPPED, sig = GDB_SIGNAL_TRAP
  [infrun] start_step_over: enter
    [infrun] start_step_over: stealing global queue of threads to step, length
= 0
    [infrun] operator(): step-over queue now empty
  [infrun] start_step_over: exit
  [infrun] context_switch: Switching context from 0.0.0 to 4185505.4185515.0
  [infrun] handle_signal_stop: stop_pc=0x5555555551af
  [infrun] bpstat_check_breakpoint_conditions: enter
    [infrun] bpstat_check_breakpoint_conditions: thread = 4185505.4185515.0,
breakpoint 921.1
    [infrun] bpstat_check_breakpoint_conditions: condition_result = false, not
stopping
  [infrun] bpstat_check_breakpoint_conditions: exit
  [infrun] process_event_stop_test: BPSTAT_WHAT_SINGLE
  [infrun] process_event_stop_test: no stepping, continue
  [infrun] stop_all_threads: start: reason=starting in-line step-over, inf=-1
    [infrun] infrun_debug_show_threads: enter
      [infrun] infrun_debug_show_threads: non-exited threads:
      [infrun] infrun_debug_show_threads:   thread 4185505.4185505.0, executing
= 1, resumed = 1, state = RUNNING
      [infrun] infrun_debug_show_threads:   thread 4185505.4185508.0, executing
= 0, resumed = 1, state = RUNNING
      [infrun] infrun_debug_show_threads:   thread 4185505.4185509.0, executing
= 0, resumed = 1, state = RUNNING
      [infrun] infrun_debug_show_threads:   thread 4185505.4185510.0, executing
= 0, resumed = 1, state = RUNNING
      [infrun] infrun_debug_show_threads:   thread 4185505.4185511.0, executing
= 0, resumed = 1, state = RUNNING
      [infrun] infrun_debug_show_threads:   thread 4185505.4185512.0, executing
= 0, resumed = 0, state = STOPPED
      [infrun] infrun_debug_show_threads:   thread 4185505.4185513.0, executing
= 0, resumed = 1, state = RUNNING
      [infrun] infrun_debug_show_threads:   thread 4185505.4185514.0, executing
= 0, resumed = 1, state = RUNNING
      [infrun] infrun_debug_show_threads:   thread 4185505.4185515.0, executing
= 0, resumed = 0, state = RUNNING
      [infrun] infrun_debug_show_threads:   thread 4185505.4185516.0, executing
= 0, resumed = 1, state = RUNNING
      [infrun] infrun_debug_show_threads:   thread 4185505.4185517.0, executing
= 0, resumed = 1, state = RUNNING
    [infrun] infrun_debug_show_threads: exit
    [infrun] stop_all_threads: pass=0, iterations=0
    [infrun] stop_all_threads:   4185505.4185505.0 executing, need stop
    [infrun] stop_all_threads:   4185505.4185508.0 not executing
    [infrun] maybe_remove_resumed_with_pending_wait_status: removing from
resumed threads with event list: 4185505.4185508.0
    [infrun] stop_all_threads:   4185505.4185509.0 not executing
    [infrun] maybe_remove_resumed_with_pending_wait_status: removing from
resumed threads with event list: 4185505.4185509.0
    [infrun] stop_all_threads:   4185505.4185510.0 not executing
    [infrun] maybe_remove_resumed_with_pending_wait_status: removing from
resumed threads with event list: 4185505.4185510.0
    [infrun] stop_all_threads:   4185505.4185511.0 not executing
    [infrun] maybe_remove_resumed_with_pending_wait_status: removing from
resumed threads with event list: 4185505.4185511.0
    [infrun] stop_all_threads:   4185505.4185512.0 not executing
    [infrun] stop_all_threads:   4185505.4185513.0 not executing
    [infrun] maybe_remove_resumed_with_pending_wait_status: removing from
resumed threads with event list: 4185505.4185513.0
    [infrun] stop_all_threads:   4185505.4185514.0 not executing
    [infrun] maybe_remove_resumed_with_pending_wait_status: removing from
resumed threads with event list: 4185505.4185514.0
    [infrun] stop_all_threads:   4185505.4185515.0 not executing
    [infrun] stop_all_threads:   4185505.4185516.0 not executing
    [infrun] maybe_remove_resumed_with_pending_wait_status: removing from
resumed threads with event list: 4185505.4185516.0
    [infrun] stop_all_threads:   4185505.4185517.0 not executing
    [infrun] maybe_remove_resumed_with_pending_wait_status: removing from
resumed threads with event list: 4185505.4185517.0
    [infrun] print_target_wait_results: target_wait (-1.0.0 [process -1],
status) =
    [infrun] print_target_wait_results:   4185505.4185505.0 [Thread
0x7ffff7cbf740 (LWP 4185505)],
    [infrun] print_target_wait_results:   status->kind = STOPPED, sig =
GDB_SIGNAL_0
    [infrun] handle_one: status->kind = STOPPED, sig = GDB_SIGNAL_0
4185505.4185505.0
    [infrun] stop_all_threads:   4185505.4185505.0 not executing
    [infrun] stop_all_threads:   4185505.4185508.0 not executing
    [infrun] stop_all_threads:   4185505.4185509.0 not executing
    [infrun] stop_all_threads:   4185505.4185510.0 not executing
    [infrun] stop_all_threads:   4185505.4185511.0 not executing
    [infrun] stop_all_threads:   4185505.4185512.0 not executing
    [infrun] stop_all_threads:   4185505.4185513.0 not executing
    [infrun] stop_all_threads:   4185505.4185514.0 not executing
    [infrun] stop_all_threads:   4185505.4185515.0 not executing
    [infrun] stop_all_threads:   4185505.4185516.0 not executing
    [infrun] stop_all_threads:   4185505.4185517.0 not executing
    [infrun] stop_all_threads: pass=1, iterations=1
    [infrun] stop_all_threads:   4185505.4185505.0 not executing
    [infrun] stop_all_threads:   4185505.4185508.0 not executing
    [infrun] stop_all_threads:   4185505.4185509.0 not executing
    [infrun] stop_all_threads:   4185505.4185510.0 not executing
    [infrun] stop_all_threads:   4185505.4185511.0 not executing
    [infrun] stop_all_threads:   4185505.4185512.0 not executing
    [infrun] stop_all_threads:   4185505.4185513.0 not executing
    [infrun] stop_all_threads:   4185505.4185514.0 not executing
    [infrun] stop_all_threads:   4185505.4185515.0 not executing
    [infrun] stop_all_threads:   4185505.4185516.0 not executing
    [infrun] stop_all_threads:   4185505.4185517.0 not executing
    [infrun] stop_all_threads: done
  [infrun] stop_all_threads: end: reason=starting in-line step-over, inf=-1
  [infrun] should_be_inserted: skipping breakpoint: stepping past insn at:
0x5555555551af
  [infrun] should_be_inserted: skipping breakpoint: stepping past insn at:
0x5555555551af
  [infrun] should_be_inserted: skipping breakpoint: stepping past insn at:
0x5555555551af
  [infrun] resume_1: step=1, signal=GDB_SIGNAL_0, trap_expected=1, current
thread [4185505.4185515.0] at 0x5555555551af
  [infrun] do_target_resume: resume_ptid=4185505.4185515.0, step=1,
sig=GDB_SIGNAL_0
  [infrun] prepare_to_wait: prepare_to_wait
  [infrun] reset: reason=handling event
  [infrun] maybe_set_commit_resumed_all_targets: enabling commit-resumed for
target native
  [infrun] maybe_call_commit_resumed_all_targets: calling commit_resumed for
target native
[infrun] fetch_inferior_event: exit
[infrun] fetch_inferior_event: enter
  [infrun] scoped_disable_commit_resumed: reason=handling event
  [infrun] random_pending_event_thread: None found.
  [infrun] fetch_inferior_event: do_target_wait returned no event
  [infrun] reset: reason=handling event
  [infrun] maybe_set_commit_resumed_all_targets: enabling commit-resumed for
target native
  [infrun] maybe_call_commit_resumed_all_targets: calling commit_resumed for
target native
[infrun] fetch_inferior_event: exit
[infrun] scoped_disable_commit_resumed: reason=attaching
[infrun] infrun_debug_show_threads: enter
  [infrun] infrun_debug_show_threads: immediately after attach:
  [infrun] infrun_debug_show_threads:   thread 4185444.4185444.0, executing =
1, resumed = 0, state = STOPPED
  [infrun] infrun_debug_show_threads:   thread 4185444.4185449.0, executing =
1, resumed = 0, state = RUNNING
  [infrun] infrun_debug_show_threads:   thread 4185444.4185450.0, executing =
1, resumed = 0, state = RUNNING
  [infrun] infrun_debug_show_threads:   thread 4185444.4185451.0, executing =
1, resumed = 0, state = RUNNING
  [infrun] infrun_debug_show_threads:   thread 4185444.4185452.0, executing =
1, resumed = 0, state = RUNNING
  [infrun] infrun_debug_show_threads:   thread 4185444.4185453.0, executing =
1, resumed = 0, state = RUNNING
  [infrun] infrun_debug_show_threads:   thread 4185444.4185454.0, executing =
1, resumed = 0, state = RUNNING
  [infrun] infrun_debug_show_threads:   thread 4185444.4185455.0, executing =
1, resumed = 0, state = RUNNING
  [infrun] infrun_debug_show_threads:   thread 4185444.4185456.0, executing =
1, resumed = 0, state = RUNNING
  [infrun] infrun_debug_show_threads:   thread 4185444.4185457.0, executing =
1, resumed = 0, state = RUNNING
  [infrun] infrun_debug_show_threads:   thread 4185444.4185458.0, executing =
1, resumed = 0, state = RUNNING
[infrun] infrun_debug_show_threads: exit
[infrun] clear_proceed_status_thread: 4185444.4185444.0
[infrun] reset: reason=attaching
[infrun] maybe_set_commit_resumed_all_targets: enabling commit-resumed for
target native
[infrun] fetch_inferior_event: enter
  [infrun] scoped_disable_commit_resumed: reason=handling event
  [infrun] do_target_wait: Found 2 inferiors, starting at #1
  [infrun] random_pending_event_thread: None found.
  [infrun] print_target_wait_results: target_wait (-1.0.0 [process -1], status)
=
  [infrun] print_target_wait_results:   4185444.4185444.0 [LWP 4185444],
  [infrun] print_target_wait_results:   status->kind = STOPPED, sig =
GDB_SIGNAL_STOP
  [infrun] handle_inferior_event: status->kind = STOPPED, sig = GDB_SIGNAL_STOP
  [infrun] infrun_async: enable=0


My interpretation of the situation is:

 - We start an inline step for a thread of inferior 2
 - We attach to a process with inferior 1
 - The initial post-attach stop event for inferior 1 gets reported before
inferior 2's "done stepping" event
 - The assertion that verifies that "if a thread is doing an in-line step over,
any event must be for that thread" fails

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-01  3:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-01  3:53 [Bug gdb/30926] New: FAIL: gdb.threads/detach-step-over.exp: breakpoint-condition-evaluation=host: target-non-stop=on: non-stop=on: displaced=off: test_detach_command: iter 921: attach (GDB internal error) simark at simark dot ca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).