gdbserver/win32: fix crash on detach

Message ID 20231206004217.21980-3-smxdev4@gmail.com
State New
Headers
Series gdbserver/win32: fix crash on detach |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Stefano Moioli Dec. 6, 2023, 12:42 a.m. UTC
  this patch fixes a crash in gdbserver whenever a process is detached.
the crash is caused by `detach` calling `remove_process` before `win32_clear_inferiors`

error message:

Detaching from process 184
../../gdbserver/inferiors.cc:160: A problem internal to GDBserver has been detec
ted.
remove_process: Assertion `find_thread_process (process) == NULL' failed.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
---
 gdbserver/win32-low.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Tom Tromey Dec. 7, 2023, 4:36 p.m. UTC | #1
>>>>> "Stefano" == Stefano Moioli <smxdev4@gmail.com> writes:

Stefano> this patch fixes a crash in gdbserver whenever a process is detached.
Stefano> the crash is caused by `detach` calling `remove_process` before `win32_clear_inferiors`

Thank you for the patch.  This looks good to me.
Approved-By: Tom Tromey <tom@tromey.com>

If you aren't able to push it, let me know and I will do it.
If you plan to do more work on gdb, we should probably get you started
on the copyright assignment work.  Let me know.

Tom
  
Tom Tromey Dec. 12, 2023, 8:19 p.m. UTC | #2
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> If you aren't able to push it, let me know and I will do it.

I didn't hear back, so I'm pushing this now.

Tom
  
Stefano Moioli Dec. 13, 2023, 11:57 p.m. UTC | #3
Sorry for the late reply, and thanks for pushing it, as I'm not able to push
directly to the gdb repository.

Regards
  Stefano

-----Original Message-----
From: Tom Tromey <tom@tromey.com> 
Sent: martedì 12 dicembre 2023 21:20
To: Tom Tromey <tom@tromey.com>
Cc: Stefano Moioli <smxdev4@gmail.com>; gdb-patches@sourceware.org
Subject: Re: [PATCH] gdbserver/win32: fix crash on detach

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> If you aren't able to push it, let me know and I will do it.

I didn't hear back, so I'm pushing this now.

Tom
  

Patch

diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 3246957ec44..0ddf60c836f 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -735,9 +735,9 @@  win32_process_target::detach (process_info *process)
     return -1;
 
   DebugSetProcessKillOnExit (FALSE);
+  win32_clear_inferiors ();
   remove_process (process);
 
-  win32_clear_inferiors ();
   return 0;
 }