-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix: Eliminate possible deadlock related to memory allocation on global heap #232
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
Conversation
|
|
|
Ah nevermind, I didn't notice this was in DetourTransactionBegin, before any thread could be suspended. This is good then. |
src/detours.cpp
Outdated
| s_nPendingThreadId = 0; | ||
|
|
||
| // There is nothing we can do if this fails. | ||
| HeapUnlock(GetProcessHeap()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really report this if it fails, because "nobody can use the global heap anymore" seems like a pretty big problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, since the heap is locked after s_nPendingThreadId is set in DetourTransactionBegin, we should probably unlock the heap before allowing another thread to start a transaction, so before resetting s_nPendingThreadId here
src/detours.cpp
Outdated
| } | ||
|
|
||
| // There is nothing we can do if this fails. | ||
| HeapUnlock(GetProcessHeap()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
|
Thanks for the feedback. I've updated the PR. |
|
|
|
@sonyps5201314 So, as I understand, the main problem with the It looks like then there's no other foolproof solution than using |
|
@adams85 |
Addresses #70 by utilizing the
HeapLock/HeapUnlockAPIs as discussed in the issue.Microsoft Reviewers: Open in CodeFlow