Skip to content

Multithread death#2680

Merged
sporksmith merged 2 commits intoshadow:mainfrom
sporksmith:multithread-death
Jan 20, 2023
Merged

Multithread death#2680
sporksmith merged 2 commits intoshadow:mainfrom
sporksmith:multithread-death

Conversation

@sporksmith
Copy link
Copy Markdown
Contributor

  • Rename SHD_SHIM_EVENT_STOP to SHD_SHIM_EVENT_PROCESS_DEATH
  • Handling SHD_SHIM_EVENT_PROCESS_DEATH: mark whole process as dead

We inject a SHD_SHIM_EVENT_PROCESS_DEATH event into each individual
managed thread when we detect the process has died.

In #2674, this ended up causing
the memory write inside Process::reap_thread to fail. Since the process
has died, we don't need to do that write at all; marking the process as
dead correctly skips this step.

I tried to write a regression test but was unable to reproduce the
issue. As in the mongodb case, I set it up so that a child thread
called abort while the thread group leader was blocked. In both cases,
we end up trying to use the thread group leader to do the write, but it
is in a zombie state since we already natively raised SIGABRT, which
kills the whole process. In my test that write works, even though the
thread group leader is in a zombie state.

I did verify that this change fixes the problem in the mongodb example,
though.

It was originally used to communicate the death of a single thread,
but we now only use it when the whole process has died.
@sporksmith sporksmith self-assigned this Jan 20, 2023
@github-actions github-actions bot added Component: Libraries Support functions like LD_PRELOAD and logging Component: Main Composing the core Shadow executable labels Jan 20, 2023
We inject a SHD_SHIM_EVENT_PROCESS_DEATH event into each individual
managed thread when we detect the process has died.

In shadow#2674, this ended up causing
the memory write inside Process::reap_thread to fail. Since the process
has died, we don't need to do that write at all; marking the process as
dead correctly skips this step.

I tried to write a regression test but was unable to reproduce the
issue. As in the mongodb case, I set it up so that a child thread
called `abort` while the thread group leader was blocked. In both cases,
we end up trying to use the thread group leader to do the write, but it
is in a zombie state since we already natively raised SIGABRT, which
kills the whole process. In my test that write *works*, even though the
thread group leader is in a zombie state.

I did verify that this change fixes the problem in the mongodb example,
though.
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 20, 2023

Codecov Report

Base: 68.15% // Head: 68.17% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (c0f5e1b) compared to base (89442dc).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2680      +/-   ##
==========================================
+ Coverage   68.15%   68.17%   +0.01%     
==========================================
  Files         202      202              
  Lines       30326    30326              
  Branches     5923     5923              
==========================================
+ Hits        20668    20674       +6     
+ Misses       4975     4972       -3     
+ Partials     4683     4680       -3     
Flag Coverage Δ
tests 68.17% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/main/host/syscall/handler/eventfd.rs 69.44% <0.00%> (-2.78%) ⬇️
src/lib/shmem/src/scmutex.rs 87.05% <0.00%> (-2.36%) ⬇️
src/main/core/sim_config.rs 54.14% <0.00%> (-1.32%) ⬇️
...c/main/utility/synchronization/count_down_latch.rs 85.10% <0.00%> (-0.54%) ⬇️
src/main/host/syscall/handler/socket.rs 68.85% <0.00%> (-0.22%) ⬇️
src/lib/tsc/tsc_test.c 12.67% <0.00%> (ø)
src/test/signal/test_signals.rs 84.64% <0.00%> (+0.35%) ⬆️
src/main/host/memory_manager/memory_mapper.rs 71.63% <0.00%> (+0.41%) ⬆️
src/main/core/scheduler/pools/bounded.rs 77.64% <0.00%> (+1.17%) ⬆️
src/main/host/syscall/handler/fcntl.rs 65.71% <0.00%> (+1.42%) ⬆️
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sporksmith sporksmith marked this pull request as ready for review January 20, 2023 21:00
@sporksmith sporksmith enabled auto-merge January 20, 2023 21:00
@sporksmith sporksmith merged commit 127ad81 into shadow:main Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Libraries Support functions like LD_PRELOAD and logging Component: Main Composing the core Shadow executable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants