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

GC_suspend can hang attempting to suspend DllMain thread #710

Open
tobil4sk opened this issue Mar 7, 2025 · 3 comments
Open

GC_suspend can hang attempting to suspend DllMain thread #710

tobil4sk opened this issue Mar 7, 2025 · 3 comments

Comments

@tobil4sk
Copy link
Contributor

tobil4sk commented Mar 7, 2025

It seems that in some cases, the SuspendThread call within GC_suspend may hang and never return if it is trying to suspend the thread that is running DllMain to detach itself:

if (SuspendThread(t->handle) != (DWORD)-1) {

This seems related to the previously fixed issue: #704. Again I am running bdwgc in the neko vm on Windows with DllMain enabled, with this commit: 5658d91, modified with a few debug print statements.

@ivmai
Copy link
Owner

ivmai commented Mar 7, 2025

Is it 64-bit build?

@tobil4sk
Copy link
Contributor Author

tobil4sk commented Mar 7, 2025

Yes, that's correct: x86-64

@tobil4sk
Copy link
Contributor Author

tobil4sk commented Mar 7, 2025

I was previously debugging by adding printf statements, however, I have now run a proper debugger on the program and removed the print statements to avoid their potential side effects. It seems that without modification, gc.dll actually hangs on GC_win32_MessageBoxA, which it attempts to run due to ResumeThread failed in suspend loop. This error happens because it runs ResumeThread on a NULL handle. It looks like between the SuspendThread and the ResumeThread, the thread handle has started closing the thread and set it to NULL.

I'm not sure why MessageBoxA hangs since the message box isn't actually showing, but I guess GC_suspend shouldn't abort on the ResumeThread failure if it is caused by a NULL handle.

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

2 participants