llvm-project/lldb
Pavel Labath df4ad3625f [lldb/linux] Fix a race in handling of simultaneous thread exits
D116372, while fixing one kind of a race, ended up creating a new one.
The new issue could occur when one inferior thread exits while another
thread initiates termination of the entire process (exit_group(2)).

With some bad luck, we could start processing the exit notification
(PTRACE_EVENT_EXIT) only to have the become unresponsive (ESRCH) in the
middle of the MonitorCallback function. This function would then delete
the thread from our list even though it wasn't completely dead (it stays
zombified until we read the WIFEXITED event). The linux kernel will not
deliver the exited event for the entire process until we process
individual thread exits.

In a pre-D116372 world, this wouldn't be a problem because we would read
this event (even though we would not know what to do with it) with
waitpid(-1). Now, when we issue invididual waitpids, this event will
never be picked up, and we end up hanging.

The fix for this is actually quite simple -- don't delete the thread in
this situation. The thread will be deleted when the WIFEXITED event
comes.

This situation was kind of already tested by
TestCreateDuringInstructionStep (which is how I found this problem), but
it was mostly accidental, so I am also creating a dedicated test which
reproduces this situation.
2022-01-05 13:21:35 +01:00
..
bindings [lldb/python] Fix dangling Event and CommandReturnObject references 2022-01-04 14:49:00 +01:00
cmake [lldb] Use `GNUInstallDirs` to support custom installation dirs. 2021-12-22 00:28:53 +00:00
docs Load binary by UUID from qProcessInfo packet fields 2021-12-23 15:20:50 -08:00
examples [lldb/plugins] Add arm64(e) support to ScriptedProcess 2021-12-06 16:11:59 -08:00
include/lldb [lldb] Remove unused AproposAllSubCommands (NFC) 2022-01-02 11:30:51 -08:00
packages/Python [lldb] Remove lldbtest.getBuildFlags 2021-12-30 12:19:24 +01:00
resources [lldb] Remove stale LLDB-Info.plist 2021-01-08 10:12:16 -08:00
scripts Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk 2021-02-25 11:32:27 +01:00
source [lldb/linux] Fix a race in handling of simultaneous thread exits 2022-01-05 13:21:35 +01:00
test [lldb/linux] Fix a race in handling of simultaneous thread exits 2022-01-05 13:21:35 +01:00
third_party/Python/module [lldb][NFC] Inclusive language: replace master/slave names for ptys 2021-11-12 10:54:18 -06:00
tools [lldb] Remove reproducer replay functionality 2021-12-17 17:14:52 -08:00
unittests [lldb] Fix PR52702 by fixing bool conversion of Mangled 2021-12-29 17:17:52 +08:00
utils [lldb] Match test dependencies name to other LLVM projects. 2021-05-21 00:10:27 -07:00
.clang-format
.clang-tidy [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
.gitignore
CMakeLists.txt [lldb] Use `GNUInstallDirs` to support custom installation dirs. 2021-12-22 00:28:53 +00:00
CODE_OWNERS.txt
LICENSE.TXT
use_lldb_suite_root.py