[PATCH 09/11] Ensure EXIT is last event, gdb/linux

Simon Marchi simark@simark.ca
Mon Mar 7 20:24:49 GMT 2022


On 2022-03-03 09:40, Pedro Alves wrote:
> This is problematic for infrun.c:stop_all_threads, which asks the
> target to report all thread exit events to infrun.  For example, in
> stop_all_threads, core GDB counts 2 threads that needs to be stopped.
> It then asks the target to stop those 2 threads (with
> target_stop(ptid)), and waits for 2 events to come back from the
> target.  Unfortunately, when waiting for events, the linux-nat target,
> due to the random event selecting mentioned above, reports the
> whole-process EXIT event even though the other thread has exited and
> its exit hasn't been reported yet.  As a consequence, stop_all_threads
> receives one event, but waits indefinitely for the second one to come.
> Effectively, GDB hangs forever.

I don't really understand how we end up waiting forever.  Why does
reporting the leader exit event first make it so we discard the event
for the other thread?

Other than that, it looks sensible to me to ensure we return events in
this order.

Simon


More information about the Gdb-patches mailing list