rust-lang / rust-lang/rust-bindgen

Stack overflow running the standalone binary as debug under Windows

Open
#2,662 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

> .\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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Windows debug run and begin at bindgen::main, builder_from_flags, and options::augment_args in the stack trace. Inspect the generated command-line parsing path and the debug binary's stack allocation; done means the standalone debug binary starts without overflowing the default Windows stack while retaining its CLI behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.