Handle QueueUserAPC2 failure during thread suspension#122768
Handle QueueUserAPC2 failure during thread suspension#122768jkotas merged 1 commit intodotnet:mainfrom
Conversation
QueueUserAPC2 can fail when the machine is under stress. Handle the failure gracefully. Fixes dotnet#122763
There was a problem hiding this comment.
Pull request overview
This PR addresses a crash issue where QueueUserAPC2 can fail when the machine is under stress. The fix gracefully handles the failure by resetting the pending activation flag and returning the actual success status instead of always returning true.
Key Changes
- Remove assertion that
QueueUserAPC2always succeeds, as it can legitimately fail under stress - Add proper error handling to reset
m_hasPendingActivationflag when the APC queueing fails - Return the actual success status instead of always returning true
|
I think originally we believed that this API does not fail for transient reasons. - Like if we set arguments correctly, have permissions to use it, etc... then it would always work. We generally can't "handle" a failure in an API that we use to suspend threads. We can hope that some other mechanism, like hijacking, will work. I guess we can ignore the failure. Not a lot of options. There is a chance the test will switch from occasional failure to occasional timeout. |
QueueUserAPC2 can fail when the machine is under stress. Handle the failure gracefully.
Fixes #122763