llvm-project/lldb/source
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
..
API [API] Remove redundant member initialization (NFC) 2022-01-02 22:44:16 -08:00
Breakpoint [lldb] Clarify StructuredDataImpl ownership 2021-12-13 21:04:51 +01:00
Commands [lldb] Remove unused AproposAllSubCommands (NFC) 2022-01-02 11:30:51 -08:00
Core Remove unused "using" (NFC) 2022-01-02 10:20:17 -08:00
DataFormatters [lldb] Summary provider for char flexible array members 2021-12-20 12:30:34 +01:00
Expression Remove redundant return and continue statements (NFC) 2021-12-24 23:17:54 -08:00
Host [lldb] Add NOLINT(modernize-use-nullptr) 2022-01-01 13:14:59 -08:00
Initialization [lldb] Make lldbVersion a full fledged library 2021-12-08 15:14:34 -08:00
Interpreter Remove redundant return and continue statements (NFC) 2021-12-24 23:17:54 -08:00
Plugins [lldb/linux] Fix a race in handling of simultaneous thread exits 2022-01-05 13:21:35 +01:00
Symbol [lldb] Use nullptr instead of 0 or NULL (NFC) 2022-01-01 11:54:25 -08:00
Target Remove redundant void arguments (NFC) 2022-01-02 10:20:19 -08:00
Utility [lldb] Use std::move in StringList (NFC) 2022-01-03 15:36:19 -08:00
Version [lldb] Use LLDB_VERSION_STRING instead of CLANG_VERSION_STRING 2021-12-13 16:58:39 -08:00
CMakeLists.txt [lldb] Make lldbVersion a full fledged library 2021-12-08 15:14:34 -08:00