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

Avoid GC_suspend aborting due to deleted thread #705

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tobil4sk
Copy link

@tobil4sk tobil4sk commented Feb 15, 2025

A thread may be deleted by a DllMain call during execution of GC_suspend.

This patch sets the handle to be NULL when deleting the thread to avoid use-after-free bugs, and skips the GC_suspend attempt if the thread handle has been closed.

Fixes #704

@tobil4sk tobil4sk changed the title Avoid GC_suspend aborting when thread was deleted Avoid GC_suspend/start_world aborting on deleted thread Feb 15, 2025
@tobil4sk tobil4sk force-pushed the fix/dllmain-race-condition branch 2 times, most recently from 035756a to bd38c40 Compare February 15, 2025 17:08
@tobil4sk tobil4sk changed the title Avoid GC_suspend/start_world aborting on deleted thread Avoid GC_suspend aborting due to deleted thread Feb 15, 2025
A thread may be deleted by a DllMain call during execution of
GC_suspend.

This patch sets the handle to be NULL when deleting the thread to avoid
use-after-free bugs, and skips the GC_suspend attempt if the thread
handle has been closed.
@tobil4sk tobil4sk force-pushed the fix/dllmain-race-condition branch from bd38c40 to 8df263b Compare February 15, 2025 17:19
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.

GC_delete_thread call from GC_DllMain interleaves with GC_suspend from GC_gcollect causing SuspendThread error
1 participant