mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-03 04:12:10 +08:00
Windows: Fix run/attach hang after bad run/attach
On Cygwin, gdb.base/attach.exp exposes that an "attach" after a previously failed "attach" hangs: (gdb) PASS: gdb.base/attach.exp: do_attach_failure_tests: attach to digits-starting nonsense is prohibited attach 0 Can't attach to process 0 (error 2: The system cannot find the file specified.) (gdb) PASS: gdb.base/attach.exp: do_attach_failure_tests: attach to nonexistent process is prohibited attach 10644 FAIL: gdb.base/attach.exp: do_attach_failure_tests: first attach (timeout) The problem is that windows_nat_target::attach always returns success even if the attach fails. When we return success, the helper thread begins waiting for events (which will never come), and thus the next attach deadlocks on the do_synchronously call within windows_nat_target::attach. "run" has the same problem, which is exposed by the new gdb.base/run-fail-twice.exp testcase added in a following patch: (gdb) run Starting program: .../gdb.base/run-fail-twice/run-fail-twice.nox Error creating process .../gdb.base/run-fail-twice/run-fail-twice.nox, (error 6: The handle is invalid.) (gdb) PASS: gdb.base/run-fail-twice.exp: test: bad run 1 run Starting program: .../gdb.base/run-fail-twice/run-fail-twice.nox FAIL: gdb.base/run-fail-twice.exp: test: bad run 2 (timeout) The problem here is the same, except that this time it is windows_nat_target::create_inferior that returns the incorrect result. This commit fixes both the "attach" and "run" paths, and the latter both the Cygwin and MinGW paths. The tests mentioned above now pass on Cygwin. Confirmed the fixes manually for MinGW GDB. Change-Id: I15ec9fa279aff269d4982b00f4ea7c25ae917239 Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
parent
d0273077cc
commit
e0139e5b03
@ -2059,7 +2059,7 @@ windows_nat_target::attach (const char *args, int from_tty)
|
||||
if (!ok)
|
||||
err = (unsigned) GetLastError ();
|
||||
|
||||
return true;
|
||||
return ok;
|
||||
});
|
||||
|
||||
if (err.has_value ())
|
||||
@ -2784,12 +2784,15 @@ windows_nat_target::create_inferior (const char *exec_file,
|
||||
windows_init_thread_list ();
|
||||
do_synchronously ([&] ()
|
||||
{
|
||||
if (!create_process (nullptr, args, flags, w32_env,
|
||||
inferior_cwd != nullptr ? infcwd : nullptr,
|
||||
disable_randomization,
|
||||
&si, &pi))
|
||||
BOOL ok = create_process (nullptr, args, flags, w32_env,
|
||||
inferior_cwd != nullptr ? infcwd : nullptr,
|
||||
disable_randomization,
|
||||
&si, &pi);
|
||||
|
||||
if (!ok)
|
||||
ret = (unsigned) GetLastError ();
|
||||
return true;
|
||||
|
||||
return ok;
|
||||
});
|
||||
|
||||
if (w32_env)
|
||||
@ -2910,16 +2913,18 @@ windows_nat_target::create_inferior (const char *exec_file,
|
||||
windows_init_thread_list ();
|
||||
do_synchronously ([&] ()
|
||||
{
|
||||
if (!create_process (nullptr, /* image */
|
||||
args, /* command line */
|
||||
flags, /* start flags */
|
||||
w32env, /* environment */
|
||||
inferior_cwd, /* current directory */
|
||||
disable_randomization,
|
||||
&si,
|
||||
&pi))
|
||||
BOOL ok = create_process (nullptr, /* image */
|
||||
args, /* command line */
|
||||
flags, /* start flags */
|
||||
w32env, /* environment */
|
||||
inferior_cwd, /* current directory */
|
||||
disable_randomization,
|
||||
&si,
|
||||
&pi);
|
||||
if (!ok)
|
||||
ret = (unsigned) GetLastError ();
|
||||
return true;
|
||||
|
||||
return ok;
|
||||
});
|
||||
if (tty != INVALID_HANDLE_VALUE)
|
||||
CloseHandle (tty);
|
||||
|
Loading…
Reference in New Issue
Block a user