Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix windows_nat_target::fake_create_process ptid
@ 2024-03-22 19:30 Pedro Alves
  2024-03-23  6:39 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2024-03-22 19:30 UTC (permalink / raw)
  To: gdb-patches

While working on Windows non-stop mode, I managed to introduce a bug
that led to fake_create_process being called.  That then resulted in
GDB crashes later on, because fake_create_process added a thread with
an incorrect ptid for this target.  It is putting dwThreadId in the
tid field of the ptid instead of on the lwp field.  This is fixed by
this patch.

I do however wonder why nobody has seen it this long.  The
fake_create_process code was added for
https://sourceware.org/bugzilla/show_bug.cgi?id=8153 and Chris said
back then, in:
  https://sourceware.org/legacy-ml/gdb-patches/2003-12/msg00479.html

  "If the main thread has exited, there is never any create process
  notification when attaching to a process.  That confuses all sorts of
  things."

Unfortunately, nowhere was it stated which version of Windows was that
observed on.  I don't see any missing CREATE_PROCESS_DEBUG_EVENT when
I try the reproducer from the bugzilla on Windows 10.  I would have to
try on Windows XP (the oldest version of Windows we claim to support),
but I don't have such a machine handy.  Do note however, that
GDBserver has never gotten an equivalent to fake_create_process.  But
I'm not sure that is proof enough that we can yank that out from GDB,
as seemingly not many people use Windows gdbserver.

Change-Id: Iaee5d2deaa57c501f7e6909f8ac242af9b183215
---
 gdb/windows-nat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index a90388922e2..a0013aa81e0 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1365,8 +1365,8 @@ windows_nat_target::fake_create_process ()
       throw_winerror_with_name (_("OpenProcess call failed"), err);
       /*  We can not debug anything in that case.  */
     }
-  add_thread (ptid_t (windows_process.current_event.dwProcessId, 0,
-			      windows_process.current_event.dwThreadId),
+  add_thread (ptid_t (windows_process.current_event.dwProcessId,
+		      windows_process.current_event.dwThreadId, 0),
 		      windows_process.current_event.u.CreateThread.hThread,
 		      windows_process.current_event.u.CreateThread.lpThreadLocalBase,
 		      true /* main_thread_p */);

base-commit: c05dd51122c2d654031b04e02ad0ea5b53ffe5e2
-- 
2.43.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-04-12 17:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-22 19:30 [PATCH] Fix windows_nat_target::fake_create_process ptid Pedro Alves
2024-03-23  6:39 ` Eli Zaretskii
2024-03-25 19:36   ` Pedro Alves
2024-03-25 19:57     ` [PATCH] New testcase gdb.threads/leader-exit-attach.exp (PR threads/8153) Pedro Alves
2024-03-26 15:26       ` Tom Tromey
2024-03-26 19:27         ` Pedro Alves
2024-03-26 20:04           ` Tom Tromey
2024-04-12 17:45       ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox