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

Finalizers may not be called when flagged VM is terminated #1101

Open
shirok opened this issue Jan 19, 2025 · 0 comments
Open

Finalizers may not be called when flagged VM is terminated #1101

shirok opened this issue Jan 19, 2025 · 0 comments

Comments

@shirok
Copy link
Owner

shirok commented Jan 19, 2025

GC queues finalizers, and it sets a flag in the VM of the sweeping thread. Once the thread resumes VM loop, it calls GC_invoke_finalizers() in a safe position, which processes the pending finalizers.

However, if the thread is terminated by another thread before that, the flag is never checked and the queued finalizers won't run.

Using a global flag involves high overhead (even lock-free check is costlier than localized memory reference).

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

No branches or pull requests

1 participant