Description
To help protect against bugs in unsafe or third-party code, the Rust compiler should emit code to enable strict HANDLE
checking for all Windows Rust programs. The process will receive a fatal error if it manipulates a HANDLE
that is not valid, such as using an uninitialized HANDLE
or calling CloseHandle
twice.
See MSDN for SetProcessMitigationPolicy
and PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY
:
Strict HANDLE
checking might cause compatibility problems for Rust programs that depends on third-party libraries that misuse HANDLE
s. As a general rule, strict HANDLE
checking cannot be turned off once it is turned on, so there would be no backdoor to allow sloppy third-party code to run without raising a HANDLE
exception. If that compatibility constraint is too severe, strict HANDLE
checking could be limited to debug builds or disabled with an opt-out compiler flag.
Here is how Firefox enables strict HANDLE
checking for its sandbox processes: