| Previous | Next |
| ERROR_ACCESS_DENIED | ERROR_ARENA_TRASHED |
ERROR_INVALID_HANDLE
A handle cannot be used by the requested API
ERROR_INVALID_HANDLE means an API received a handle value that does not refer to a valid compatible kernel object in the current process. Typical causes include double-close bugs, uninitialized fields, ownership mistakes, and using a pseudo-handle where a real handle is required.
Debugging steps
- Trace where the handle was created, transferred, duplicated, and closed.
- Initialize handle variables to the documented invalid value and reset them after close.
- Check that the handle type matches the called API.
- Review races where one thread closes an object while another still uses it.
Prevention
Give each handle a clear owner and use scope-bound wrappers in C++ where possible. A retry with the same handle is not meaningful; recreate the underlying object after fixing the lifetime problem.
References
Looking for a different code? Search another status or error code.