Skip to content

Windows 7: std::io::last_os_error is set after printing to stdout #53155

Closed
@nicokoch

Description

@nicokoch

This happens on Windows 7, cannot test on newer Windows.
Basically, something wrong happens with file handles when using the println! macro, not sure what exactly.

Minimal repro:

use std::io;
fn main() {
    println!("{:?}", io::Error::last_os_error());
    println!("{:?}", io::Error::last_os_error());
}

Actual output:

Os { code: 0, kind: Other, message: "Der Vorgang wurde erfolgreich beendet." }
Os { code: 6, kind: Other, message: "Das Handle ist ungültig." }

Expected output:

Os { code: 0, kind: Other, message: "Der Vorgang wurde erfolgreich beendet." }
Os { code: 0, kind: Other, message: "Der Vorgang wurde erfolgreich beendet." }

Sorry for German localization in the error messages.

I noticed this because of some obscure behaviour in the windows API (a function returned != 0, but LastError wasn't set accordingly).

cc @retep998
cc retep998/winapi-rs#658

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-windowsOperating system: WindowsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions