| Previous | Next |
| STATUS_THREADPOOL_FREE_LIBRARY_ON_COMPLETION_FAILED | STATUS_CALLBACK_RETURNED_WHILE_IMPERSONATING |
STATUS_THREADPOOL_RELEASED_DURING_OPERATION
Thread-pool destruction raced with callback submission
Thread-pool objects and callback objects have coordinated but distinct lifetimes. This status exposes a teardown race in which the pool became unavailable while a work, timer, wait, or I/O path was publishing a callback. Checking a shutdown flag before submission is insufficient unless the check and lifetime reference are synchronized.
A robust design stops producers, prevents new submissions, disarms timers and waits, cancels or drains callbacks, closes callback objects, and only then closes the pool. Reversing those steps leaves a window where valid producer code targets released infrastructure.
What to inspect
- Log the submitting thread, callback object, pool generation, shutdown phase, and first close operation.
- Use a reference or lock that covers both the permission check and the actual submission.
- Stop external producers before draining cleanup-group members.
- Do not free callback contexts until canceled and executing callbacks have both been accounted for.
References
- Microsoft Open Specifications: NTSTATUS values
- Microsoft: CloseThreadpoolCleanupGroupMembers
- Microsoft: Thread Pool API
- Microsoft: pooled threads and callback environments
Looking for a different code? Search another status or error code.
