Closed
Description
This was initially reported in rust-cli/env_logger#214, but I'm adding it here for additional eyes and because this issue doesn't occur on stable Rust. I could be wrong but this looks like this is caused by #87329 ... cc @sunfishcode ?
I spent an hour trying to reduce a minimal test case for this error I started experiencing with my app. 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)
Here's a stack trace from windbg:
[0x0] windows_explodey!panic_abort::__rust_start_panic::abort + 0x5
[0x1] windows_explodey!panic_abort::__rust_start_panic + 0x6
[0x2] windows_explodey!std::panicking::rust_panic + 0x1b
[0x3] windows_explodey!std::panicking::rust_panic_with_hook + 0x297
[0x4] windows_explodey!std::panicking::begin_panic_handler::closure$0 + 0x6f
[0x5] windows_explodey!std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure$0,never$> + 0x17
[0x6] windows_explodey!std::panicking::begin_panic_handler + 0x49
[0x7] windows_explodey!core::panicking::panic_fmt + 0x30
[0x8] windows_explodey!core::panicking::panic + 0x4c
[0x9] windows_explodey!std::os::imp::windows::io::handle::impl$11::from_raw_handle + 0x4c
[0xa] windows_explodey!std::os::imp::windows::io::raw::impl$7::from_raw_handle + 0x13
[0xb] windows_explodey!winapi_util::win::HandleRef::from_raw_handle + 0xe
[0xc] windows_explodey!winapi_util::win::HandleRef::stderr + 0x27
[0xd] windows_explodey!winapi_util::console::HandleKind::handle + 0x27
[0xe] windows_explodey!winapi_util::console::Console::create_for_stream + 0x22
[0xf] windows_explodey!winapi_util::console::Console::stderr + 0x1d
[0x10] windows_explodey!termcolor::BufferWriter::create + 0x59
[0x11] windows_explodey!termcolor::BufferWriter::stderr + 0x22
[0x12] windows_explodey!env_logger::fmt::writer::termcolor::imp::BufferWriter::stderr + 0x49
[0x13] windows_explodey!env_logger::fmt::writer::Builder::build + 0x133
[0x14] windows_explodey!env_logger::Builder::build + 0x46
[0x15] windows_explodey!env_logger::Builder::try_init + 0x1c
[0x16] windows_explodey!env_logger::try_init_from_env<env_logger::Env> + 0x39
[0x17] windows_explodey!env_logger::try_init + 0x1b
[0x18] windows_explodey!env_logger::init + 0x9
[0x19] windows_explodey!windows_explodey::main + 0x9
If I'm reading this correctly, the panic is from this assertion:
rust/library/std/src/os/windows/io/handle.rs
Line 183 in 50171c3