Skip to content

Unregister threads with ChildPidWatcher#2806

Merged
sporksmith merged 2 commits intoshadow:mainfrom
sporksmith:unregister-processes
Mar 27, 2023
Merged

Unregister threads with ChildPidWatcher#2806
sporksmith merged 2 commits intoshadow:mainfrom
sporksmith:unregister-processes

Conversation

@sporksmith
Copy link
Copy Markdown
Contributor

We were failing to save the ChildPidWatcher notification handles, which
in turn meant we weren't unregistering threads with the ChildPidWatcher
after they exited, thus creating a resource leak. The relevant data was
still getting freed when the whole Process exited, so it would have only
affected Processes that had many threads start and end over their
lifetime.

The callback registered for each thread is only about 16 bytes - a
function pointer and a data pointer.

Additionally this fixes a bug causing a panic when we do unregister a callback for a process that's already been unregistered.

We were failing to save the ChildPidWatcher notification handles, which
in turn meant we weren't unregistering threads with the ChildPidWatcher
after they exited, thus creating a resource leak. The relevant data was
still getting freed when the whole Process exited, so it would have only
affected Processes that had many threads start and end over their
lifetime.

The callback registered for each thread is only about 16 bytes - a
function pointer and a data pointer.
…ered

The watcher may have already unregistered the pid if it already detected
its exit and executed the callbacks.
@github-actions github-actions bot added Component: Documentation In-repository documentation, under docs/ Component: Main Composing the core Shadow executable labels Mar 24, 2023
@sporksmith sporksmith requested a review from stevenengler March 24, 2023 22:14
@sporksmith
Copy link
Copy Markdown
Contributor Author

The ChildPidWatcher could use some more cleanup, but just doing the minimal fix for now to fix the resource leak.

@sporksmith sporksmith merged commit 44cd87e into shadow:main Mar 27, 2023
@sporksmith sporksmith deleted the unregister-processes branch March 27, 2023 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Documentation In-repository documentation, under docs/ Component: Main Composing the core Shadow executable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants