-
Notifications
You must be signed in to change notification settings - Fork 746
Struct with too many fields causes stack overflow in tests #2218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a regression from #2203, which creates a The tests look like: assert_eq!(
unsafe {
let uninit = ::std::mem::MaybeUninit::<MyStruct>::uninit();
let ptr = uninit.as_ptr();
::std::ptr::addr_of!((*ptr).field_694) as usize - ptr as usize
},
5552usize,
concat!(
"Offset of field: ",
stringify!(MyStruct),
"::",
stringify!(field_694)
)
);
assert_eq!(
unsafe {
let uninit = ::std::mem::MaybeUninit::<MyStruct>::uninit();
let ptr = uninit.as_ptr();
::std::ptr::addr_of!((*ptr).field_695) as usize - ptr as usize
},
5560usize,
concat!(
"Offset of field: ",
stringify!(MyStruct),
"::",
stringify!(field_695)
)
); It seems |
Indeed, I also copy-pasted the assertions to Should I file an issue with rustc? |
Well, sorta, we can work around it. But yeah it'd be nice if rustc didn't use so much stack space. |
So that rustc doesn't take too much stack space without optimizations. Fixes #2218
#2219 has a fix / workaround. |
That was fast! I also tried to surround each I tested godot-rust locally with the revision from your PR: bindgen = { git = "https://github.com/rust-lang/rust-bindgen.git", rev = "7fe8e55847af1f9c26f1ad5b5e78f178a2d53f7f", default-features = false, features = ["runtime"] } And the tests pass now! |
Yeah, I had tried that locally as well, hoping that'd work too but... :)
Awesome, thanks for confirming. |
So that rustc doesn't take too much stack space without optimizations. Fixes #2218
Published 0.60.1 with that workaround. |
Thanks a lot for the quick help with this! |
So that rustc doesn't take too much stack space without optimizations. Fixes rust-lang#2218
The newly released bindgen 0.60.0 introduces a regression in generated tests. When using a struct with a large number of fields, the tests cause a stack overflow. This could also be an issue in rustc itself.
I discovered it in godot-rust/gdnative#897 (this CI run) and could reproduce it locally.
Input C/C++ Header
For me, the threshold was 694 fields (693 worked fine); this might differ on other machines depending on stack size. So consider increasing the number of fields if you can't reproduce it with below code.
Click to expand
Bindgen Invocation
No special flags.
Actual Results
Codegen works fine, running tests causes runtime crash.
Expected Results
Well... tests don't crash 🙂
The text was updated successfully, but these errors were encountered: