Re: [PATCH] [gdb/tdep] Don't call WaitForSingleObject with INFINITE arg

Tom de Vries
2025-06-10T07:13:50Z

On 6/6/25 15:11, Pedro Alves wrote:
> On 2025-06-05 17:15, Pedro Alves wrote:
>>> However, testsuite progress ground to a halt at
>>> gdb.base/branch-to-self.exp. [ AFAICT, similar problems reported
>>> here [1]. ]
>> The testsuite fails to kill gdb all the time for me, it may well be
>> the same. I'll give it a try after you've merged it.
>>
>
> I tested this now, and, unfortunately, it makes no difference for me.

Hi Pedro,

that's a pity.

FWIW, I've rebuild gdb from scratch, this time with -O0, ran the
test-case 10 times, and it finished every time.

> With upstream from before your patch, and I do see a gdb.base/branch-to-self.exp hang.
>
> However, after your patch, I still see the same hang.
>
> If I attach another GDB to the hung GDB, I see several other GDB threads stopped in
> WaitForMultipleObjects with an INFINITE argument, in Cygwin code, so I'm puzzled on
> how changing that particular call made a difference for you. :-/ Wonder if it's just
> a happy coincidence of affecting the scheduling.
>

Could be, I'm not sure.

FWIW, I've now managed to run the testsuite until gdb.base.sigterm.exp,
and it's stuck there.

> I've long suspected that this is actually some deadlock bug in Cygwin somewhere around
> closing stdin/stdout, and I still suspect so. But I can't discard it being a GDB bug.
>

If cygwin is problematic, I'm happy to ignore it and use one of the
other setups.

I've tried msys2, but also there I run into trouble (
https://sourceware.org/bugzilla/show_bug.cgi?id=33072 ) and I get even
less far than on cygwin: starting gdb is a problem because it produces
some control characters that the testsuite doesn't expect, and I can't
debug it because the gdb executable is missing debug info.

> I didn't use to have this issue maybe a year ago, then I stopped working on Windows for a
> few months, and when I got back at it, I started seeing the issue. It's like some Cygwin
> update, or Windows update caused the issue.

I also wonder whether it's easy to introduce regressions in gdb by
testing mingw but not cygwin.

Anyway, my windows/cygwin setup is fresh. I bought a windows laptop
this spring with windows 11 home, and installed cygwin on it.

> The hang is like other hangs I've observed before, it's around closing GDB to restart it
> for more tests, and the patch at:
>
> https://sourceware.org/pipermail/gdb-patches/2025-May/217949.html
>
> still helps with it for me. With that one on top of yours, and with
> gdb.base/branch-to-self.exp, I get:
>
> WARNING: closing gdb failed with: child process exited abnormally
>
> (the same as what I get without your patch) and the testcase moves on and
> finishes properly (though a couple tests fail with timeout, as they do for you.)
>

I've not seen that failure mode sofar, but thanks for the fix, that
looks useful.

> If I look at the task manager while doing a full testsuite run, I see a bunch of leftover
> gdb.exe processes and their children still running, because dejagnu fails to properly
> close gdb.exe.

I also see other cases of processes left behind. I've filed this
(https://sourceware.org/bugzilla/show_bug.cgi?id=33061 ) for one of those.

I've also got a patch submitted here (
https://patchwork.sourceware.org/project/gdb/patch/20250217163619.8662-3-tdevries@suse.de/
) for another case.

Thanks,
- Tom