]> git.proxmox.com Git - mirror_qemu.git/commit - gdbstub.c
gdbstub: handle a potentially racing TaskState
authorAlex Bennée <alex.bennee@linaro.org>
Mon, 29 Nov 2021 14:09:29 +0000 (14:09 +0000)
committerAlex Bennée <alex.bennee@linaro.org>
Mon, 29 Nov 2021 15:13:12 +0000 (15:13 +0000)
commita8e537fa4d61b29c5c0ab1395918ad63f7752b25
treedb57f4e3b62bd91f1004de9303b242fbbb2b4e38
parent86a41ac7fd488ce084175a30d1e5fd92dc37596b
gdbstub: handle a potentially racing TaskState

When dealing with multi-threaded userspace programs there is a race
condition with the addition of cpu->opaque (aka TaskState). This is
due to cpu_copy calling cpu_create which updates the global vCPU list.
However the task state isn't set until later. This shouldn't be a
problem because the new thread can't have executed anything yet but
the gdbstub code does liberally iterate through the CPU list in
various places.

This sticking plaster ensure the not yet fully realized vCPU is given
an pid of -1 which should be enough to ensure it doesn't show up
anywhere else.

In the longer term I think the code that manages the association
between vCPUs and attached GDB processes could do with a clean-up and
re-factor.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/730
Message-Id: <20211129140932.4115115-6-alex.bennee@linaro.org>
gdbstub.c