Skip to content
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

Thread 'main' panicked at 'called Result::unwrap() on an Err value: FromBytesWithNulError { kind: InteriorNul(29) } #2566

Closed
XVilka opened this issue Jun 26, 2023 · 5 comments · Fixed by #2567

Comments

@XVilka
Copy link

XVilka commented Jun 26, 2023

Input C/C++ Header

Sorry, but I wasn't able to reduce headers for some reason - error disappears. I am attaching the full project and an archive with the Rizin headers.

The system is macOS ARM64 13.4

bindgen-crash-reproducer.zip

rizin-headers.zip

error_report.log.zip

The headers are of the Rizin project: https://github.com/rizinorg/rizin

Bindgen Invocation

See build.rs in the attached archive

Actual Results

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: FromBytesWithNulError { kind: InteriorNul(29) }', /Users/anton.kochkov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.1/codegen/mod.rs:717:71
  stack backtrace:
     0:        0x1047a73cc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf56058dac04a8100
     1:        0x1047d6cc0 - core::fmt::write::h887ee594c50d2f6b
     2:        0x1047b454c - std::io::Write::write_fmt::h8e068fbe7ba944b7
     3:        0x1047a71dc - std::sys_common::backtrace::print::hefee1a8be582057a
     4:        0x1047b1b78 - std::panicking::default_hook::{{closure}}::h7ba479390a999ae5
     5:        0x1047b1840 - std::panicking::default_hook::hc4ff20421fd3aa8b
     6:        0x1047b2188 - std::panicking::rust_panic_with_hook::h97e5266e8ce2f24f
     7:        0x1047a76b8 - std::panicking::begin_panic_handler::{{closure}}::h5c38d4c71a65b53e
     8:        0x1047a74c4 - std::sys_common::backtrace::__rust_end_short_backtrace::h9c79ccffe3575672
     9:        0x1047b1da4 - _rust_begin_unwind
    10:        0x1047f1a10 - core::panicking::panic_fmt::h8d86c61b68da2636
    11:        0x1047f1978 - core::result::unwrap_failed::h2eeab09a9c5ad8bf
    12:        0x1042d8030 - core::result::Result<T,E>::unwrap::h1b98d57917a790d1
                                 at /private/tmp/rust-20230613-7622-103lepv/rustc-1.70.0-src/library/core/src/result.rs:1089:23
    13:        0x1042dd688 - <bindgen::ir::var::Var as bindgen::codegen::CodeGenerator>::codegen::hfa34c4704686e659
                                 at /Users/anton.kochkov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.1/codegen/mod.rs:717:32
    14:        0x1043dbb70 - <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen::h6555b708a86e7e40
                                 at /Users/anton.kochkov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.1/codegen/mod.rs:540:17
    15:        0x1043dc458 - <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen::{{closure}}::h0ab018d8d97f5085
                                 at /Users/anton.kochkov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.1/codegen/mod.rs:566:21
    16:        0x1043dbd68 - <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen::hb4681d111f39a976
                                 at /Users/anton.kochkov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.1/codegen/mod.rs:596:13
    17:        0x1043dbb10 - <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen::h6555b708a86e7e40
                                 at /Users/anton.kochkov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.1/codegen/mod.rs:534:17
    18:        0x1043e52a0 - bindgen::codegen::codegen::{{closure}}::h92236ee983b08dc7
                                 at /Users/anton.kochkov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.1/codegen/mod.rs:4719:9
    19:        0x1042bc200 - bindgen::ir::context::BindgenContext::gen::h2137dffcdda25f99
                                 at /Users/anton.kochkov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.1/ir/context.rs:1218:19
    20:        0x1043e4764 - bindgen::codegen::codegen::h98b27d48bd6c34e1
                                 at /Users/anton.kochkov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.1/codegen/mod.rs:4683:5
    21:        0x1042c9940 - bindgen::Bindings::generate::hbd2b5f712cc64035
                                 at /Users/anton.kochkov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.1/lib.rs:896:13
    22:        0x1042c7b84 - bindgen::Builder::generate::hd4e381d53245babd
                                 at /Users/anton.kochkov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.1/lib.rs:338:9
    23:        0x10425afa4 - build_script_build::main::h42d09c1057897f8a
                                 at /Users/anton.kochkov/Misc/bindgen-crash-reproducer/build.rs:51:20
    24:        0x10425b470 - core::ops::function::FnOnce::call_once::hf83113fa8666a300
                                 at /private/tmp/rust-20230613-7622-103lepv/rustc-1.70.0-src/library/core/src/ops/function.rs:250:5
    25:        0x10425a458 - std::sys_common::backtrace::__rust_begin_short_backtrace::hdcfdf19e930f4e76
                                 at /private/tmp/rust-20230613-7622-103lepv/rustc-1.70.0-src/library/std/src/sys_common/backtrace.rs:134:18
    26:        0x10425c018 - std::rt::lang_start::{{closure}}::hf4635be123a6423d
                                 at /private/tmp/rust-20230613-7622-103lepv/rustc-1.70.0-src/library/std/src/rt.rs:166:18
    27:        0x1047b1cc8 - std::panicking::try::hd27950ade386a4c1
    28:        0x1047bcb14 - std::rt::lang_start_internal::h4c832f79c4cb8516
    29:        0x10425bfe4 - std::rt::lang_start::h3cc6ef3008c55f2f
                                 at /private/tmp/rust-20230613-7622-103lepv/rustc-1.70.0-src/library/std/src/rt.rs:165:17
    30:        0x10425b150 - _main

Expected Results

No crash

@XVilka XVilka changed the title hread 'main' panicked at 'called Result::unwrap() on an Err value: FromBytesWithNulError { kind: InteriorNul(29) } Thread 'main' panicked at 'called Result::unwrap() on an Err value: FromBytesWithNulError { kind: InteriorNul(29) } Jun 26, 2023
@XVilka
Copy link
Author

XVilka commented Jun 26, 2023

If I downgrade bindgen version to 0.65.x - it works fine. So it's a regression.

@XVilka XVilka mentioned this issue Jun 26, 2023
@emilio
Copy link
Contributor

emilio commented Jun 26, 2023

Regression from 46a08b0, cc @reitermarkus

@emilio
Copy link
Contributor

emilio commented Jun 26, 2023

Minimal repro:

#define FOO "a\0b"

emilio added a commit to emilio/rust-bindgen that referenced this issue Jun 26, 2023
And fix a crash when strings have interior nulls.

Fixes rust-lang#2566
emilio added a commit to emilio/rust-bindgen that referenced this issue Jun 26, 2023
And fix a crash when strings have interior nulls.

Fixes rust-lang#2566
emilio added a commit to emilio/rust-bindgen that referenced this issue Jun 26, 2023
And fix a crash when strings have interior nulls.

Fixes rust-lang#2566
emilio added a commit that referenced this issue Jun 26, 2023
And fix a crash when strings have interior nulls.

Fixes #2566
@XVilka
Copy link
Author

XVilka commented Jun 27, 2023

Thanks for such a quick fix!

@ShayBox
Copy link

ShayBox commented Jul 16, 2023

Just ran into this myself, glad to see it's already been fixed in git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants