Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unregister threads with ChildPidWatcher #2806

Merged
merged 2 commits into from
Mar 27, 2023

Conversation

sporksmith
Copy link
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
Copy link
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.

None yet

2 participants