Re: [PATCH 3/8] gdb: replace inferior::waiting_for_vfork_done with inferior::thread_waiting_for_vfork_done

Pedro Alves
2022-03-31T18:18:22Z

On 2022-01-17 16:27, Simon Marchi via Gdb-patches wrote:
> The inferior::waiting_for_vfork_done flag indicates that some thread in
> that inferior is waiting for a vfork-done event. Subsequent patches
> will need to know which thread is waiting for that event.
>
> I think there is a latent buglet in that waiting_for_vfork_done is
> currently not reset on inferior exec or exit. I could imagine that if a
> thread in the parent process calls exec or exit while another thread of
> the parent process is waiting for its vfork child to exec or exit, we
> could end up with inferior::waiting_for_vfork_done without a thread
> actually waiting for a vfork-done event anymore. And since that flag is
> checked in resume_1, things could misbehave there.
>
> Since the new field points to a thread_info object, and those are
> destroyed on exec or exit, it could be worse now since we could try to
> access freed memory, if thread_waiting_for_vfork_done were to point to a
> stale thread_info. To avoid this, clear the field in
> infrun_inferior_exit and infrun_inferior_execd.

This is OK, please mention explicitly in the body of the commit log that this
is replacing the boolean with a thread_info pointer. Not having that
actually gave me pause.