-
Notifications
You must be signed in to change notification settings - Fork 239
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
Wait for the overlapped operation to be signaled as canceled #326
Conversation
… OS set the `internal` flag to STATUS_CANCELED). If the wil::unique_folder_change_reader_nothrow handle is destroyed before that, a random memory corruption or crash might occur.
Neat, thanks - MSDN says
And passing Good catch! One common problem with these callback types is if they are destroyed on the same thread as the callback. So like if the watcher is invoked on a thread, then as part of its operation it initiates teardown, that can cause these "block for completion" parts of destructors to hang. A common workaround is to track the thread ID in the "handle callback" and if the destroying thread is the same as the callback thread, don't block. I haven't done enough overlapped IO to know if GetOverlappedResult has that problem. |
I don't think that |
This might seem wild, but I think we (Windows Terminal) are hitting deadlocks on shutdown after upgrading to a version of WIL that has this change. The callstack points to...
How are we holding it wrong? I'd love to hold it right :) |
We are seeing the same behavior during our internal tests and I analyzed a memory dump. What I found is that Based on the above, I reproduced synthetically a scenario when the above hang can take place. There is a race condition where if you receive a monitor notification and you delete the directory before issuing a new call to StartIo, the |
let the OS set the
internal
flag to STATUS_CANCELED). If the wil::unique_folder_change_reader_nothrow handle is destroyed before doing that, a random memory corruption or crash might occur.