rust-cli / env_logger

A logging implementation for `log` which is configured via an environment variable.
https://docs.rs/env_logger
Apache License 2.0
803 stars 125 forks source link

panic (?) with #[windows_subsystem = "windows"] on Rust nightly #214

Closed parasyte closed 3 years ago

parasyte commented 3 years ago

I spent an hour trying to reduce a minimal test case for this error I started experiencing with my app. I don't know if this is the right repo to track this, but so far I have produced the following:

[package]
name = "windows_explodey"
version = "0.1.0"
edition = "2018"
resolver = "2"

[dependencies]
env_logger = "0.9"

[profile.release]
panic = "abort"
#![windows_subsystem = "windows"]

fn main() {
    env_logger::init();

    println!("Hello, world!");
}

When running this on any nightly compiler since nightly-2021-08-21, I get an error like this:

$ cargo +nightly-2021-08-21 run
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target\debug\windows_explodey.exe`
error: process didn't exit successfully: `target\debug\windows_explodey.exe` (exit code: 101)

Adjusting the profile to panic = "abort" causes an even more ominous error:

$ cargo +nightly-2021-08-21 run --release
    Finished release [optimized] target(s) in 0.03s
     Running `target\release\windows_explodey.exe`
error: process didn't exit successfully: `target\release\windows_explodey.exe` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)

I recognize it's probably silly to use #[windows_subsystem = "windows"] with env_logger. My workaround for now is conditionally calling env_logger::init() only on macOS and Linux.

parasyte commented 3 years ago

I did some more digging and decided to report this upstream. Apologies for the noise!

categulario commented 2 years ago

I just experienced this issue. I think it would be helpful to have a heads-up message in the docs about it