Skip to content

Windows 8 is returning ERROR_INVALID_HANDLE instead of NotFound when opening a missing file #95154

Closed
@ehuss

Description

@ehuss

I tried this code:

use std::fs::File;
use std::io::ErrorKind;

fn main() {
    let err = File::open("foo").unwrap_err();
    assert_eq!(err.kind(), ErrorKind::NotFound);
}

I expected to see this happen: Runs without error.

Instead, this happened: On Windows 8, it fails with error:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `Uncategorized`,
 right: `NotFound`', src\main.rs:6:5

This seems to have started with #94572, cc @sunfishcode.

This is causing cargo new to fail on Windows 8, cc rust-lang/cargo#10464

This may also be responsible for rustc's incremental support to complain, though this doesn't always happen:

warning: could not load dep-graph from `\\?\C:\Temp\empty\target\debug\incremental\empty-2s9a0rpxj1834\s-g83mc5algm-1qawwn9-working\dep-graph.bin`: The handle is invalid. (os error 6)

Meta

rustc --version --verbose:

rustc 1.61.0-nightly (8d60bf427 2022-03-19)
binary: rustc
commit-hash: 8d60bf427a4b055f464122062e76b3ec34d4f8ba
commit-date: 2022-03-19
host: x86_64-pc-windows-msvc
release: 1.61.0-nightly
LLVM version: 14.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-windowsOperating system: WindowsP-highHigh priorityregression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions