rust-bindgen
rust-bindgen copied to clipboard
Stack overflow running the standalone binary as debug under Windows
> .\target\debug\bindgen.exe
thread 'main' has overflowed its stack
Stack trace:
bindgen.exe!__chkstk() Line 109 Unknown
> bindgen.exe!bindgen::options::impl$3::augment_args(clap::builder::command::Command __clap_app) Line 90 Unknown
bindgen.exe!bindgen::options::impl$1::command() Line 90 Unknown
bindgen.exe!clap::derive::Parser::parse_from<bindgen::options::BindgenCommand,std::env::Args,alloc::string::String>(std::env::Args itr) Line 107 Unknown
bindgen.exe!bindgen::options::builder_from_flags<std::env::Args>(std::env::Args args) Line 453 Unknown
bindgen.exe!bindgen::main() Line 39 Unknown
bindgen.exe!core::ops::function::FnOnce::call_once<void (*)(),tuple$<>>(void(*)()) Line 250 Unknown
[Inline Frame] bindgen.exe!core::hint::black_box(tuple$<>) Line 135 Unknown
bindgen.exe!std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<>>(void(*)() f) Line 141 Unknown
bindgen.exe!std::rt::lang_start::closure$0<tuple$<>>(std::rt::lang_start::closure_env$0<tuple$<>> *) Line 166 Unknown
[Inline Frame] bindgen.exe!std::rt::lang_start_internal::closure$2() Line 148 Unknown
[Inline Frame] bindgen.exe!std::panicking::try::do_call() Line 500 Unknown
[Inline Frame] bindgen.exe!std::panicking::try() Line 464 Unknown
[Inline Frame] bindgen.exe!std::panic::catch_unwind() Line 142 Unknown
bindgen.exe!std::rt::lang_start_internal() Line 148 Unknown
bindgen.exe!std::rt::lang_start<tuple$<>>(void(*)() main, __int64 argc, unsigned char * * argv, unsigned char sigpipe) Line 165 Unknown
[External Code]
The offending assembly:
00007FF75ED17A1C mov eax,0C7898h
00007FF75ED17A21 call __chkstk (07FF75F54C660h)
00007FF75ED17A26 sub rsp,rax
It seems like that frame it's trying to allocate some 800kb on the stack, which added is more than the 1mb default stack space on windows.
I suppose it's not a big problem because most people will never run the debug version, but it's still quite inconvenient.
Maybe increasing the stack space with a linker flag would work?
Something like this in build.rs
worked for me:
fn main() {
println!("cargo:rustc-link-arg=/STACK:2097152");
}