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

Enter busy state while destroying threads #412

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

schveiguy
Copy link
Contributor

The mThreadList lock is taken while doing a whole host of things, such as scanning, or signaling.

If we don't enter the busy state, we could be paused while holding the lock to remove the thread, and this will deadlock the collection.

@schveiguy schveiguy marked this pull request as ready for review December 4, 2024 05:11
@deadalnix
Copy link
Contributor

This does not work. once the thread is deregistered, if it has a pending signal, it's be suspended and never resumed.

Copy link
Contributor

@deadalnix deadalnix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that the right way here is to detach before terminating the thread.

@schveiguy
Copy link
Contributor Author

No, because the signal could be pending, or could have been received and then the state is delayed.

Since we know the thread is going away and about to be removed from the list, the right answer is to mark somehow that the thread should ignore the signal.

I think I know how to do this -- enterBusyState, but never exit. Then the signal will be ignored, and it won't suspend.

mThreadList lock, which is used in GC cycles.
@deadalnix
Copy link
Contributor

That wasn't the expected solution, but i think it works.

The obvious follow up question for me is whether we should start thread in busy state right away. That seems like the right thing to do.

@deadalnix deadalnix merged commit 86e75b3 into snazzy-d:master Dec 4, 2024
3 of 5 checks passed
@schveiguy schveiguy deleted the fixdestroythread branch December 4, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants