What does NTSTATUS 0xC0000721 (STATUS_CALLBACK_RETURNED_THREAD_AFFINITY) mean?

 
Previous Next
STATUS_CALLBACK_RETURNED_PRI_BACK STATUS_LPC_HANDLE_COUNT_EXCEEDED

STATUS_CALLBACK_RETURNED_THREAD_AFFINITY

The callback leaked a CPU-affinity change

Setting thread affinity constrains the physical worker to selected processors. Because pool workers are reused, a callback that leaves a modified mask can pin unrelated work, overload one CPU group, defeat scheduler balancing, or violate assumptions made by later callbacks.

Affinity used for a short hardware-sensitive section must be restored to the exact previous value on the same thread. For broader workload placement, prefer pool sizing, CPU Sets, or application-owned threads instead of mutating transient worker state.

What to inspect

  • Capture entry and exit affinity, processor group, CPU Set configuration, callback identity, and worker thread ID.
  • Use the return value of SetThreadAffinityMask to restore the prior mask.
  • Handle exceptions and early returns with structured restoration.
  • Check third-party codecs, benchmark helpers, and NUMA libraries that may change affinity internally.

References


Looking for a different code? Search another status or error code.