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

build error #2565

Closed
kouzhudong opened this issue Jun 25, 2023 · 3 comments
Closed

build error #2565

kouzhudong opened this issue Jun 25, 2023 · 3 comments

Comments

@kouzhudong
Copy link

Input C/C++ Header

// Insert your minimal C or C++ header here.

Bindgen Invocation

    // Configure and generate bindings.
    let bindings = bindgen::builder()
        .header("../inc/libnet.h")
        //.clang_arg("-x").clang_arg("c++")
        .generate()
        .expect("Couldn't write bindings!");

    // Write the generated bindings to an output file.
    bindings
        .write_to_file("../inc/libnet.rs")
        .expect("Couldn't write bindings!");

or

$ bindgen input.h --whatever --flags

Actual Results

  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: FromBytesWithNulError { kind: InteriorNul(17) }', C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bindgen-0.66.1\codegen\mod.rs:717:71
  stack backtrace:
     0:     0x7ff723483482 - std::backtrace_rs::backtrace::dbghelp::trace
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:98
     1:     0x7ff723483482 - std::backtrace_rs::backtrace::trace_unsynchronized
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
     2:     0x7ff723483482 - std::sys_common::backtrace::_print_fmt
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\sys_common\backtrace.rs:65
     3:     0x7ff723483482 - std::sys_common::backtrace::_print::impl$0::fmt
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\sys_common\backtrace.rs:44
     4:     0x7ff7234a426b - core::fmt::write
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\core\src\fmt\mod.rs:1254
     5:     0x7ff72347e27a - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\io\mod.rs:1698
     6:     0x7ff7234831cb - std::sys_common::backtrace::_print
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\sys_common\backtrace.rs:47
     7:     0x7ff7234831cb - std::sys_common::backtrace::print
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\sys_common\backtrace.rs:34
     8:     0x7ff723485d9a - std::panicking::default_hook::closure$1
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\panicking.rs:269
     9:     0x7ff723485a00 - std::panicking::default_hook
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\panicking.rs:288
    10:     0x7ff723486476 - std::panicking::rust_panic_with_hook
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\panicking.rs:691
    11:     0x7ff72348636e - std::panicking::begin_panic_handler::closure$0
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\panicking.rs:582
    12:     0x7ff723484129 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\sys_common\backtrace.rs:150
    13:     0x7ff723486080 - std::panicking::begin_panic_handler
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\panicking.rs:578
    14:     0x7ff7234bb715 - core::panicking::panic_fmt
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\core\src\panicking.rs:67
    15:     0x7ff7234bbd36 - core::result::unwrap_failed
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\core\src\result.rs:1687
    16:     0x7ff722ff745d - core::result::Result<T,E>::unwrap::h22228f8087ff7b38
    17:     0x7ff722ffb53d - <bindgen::ir::var::Var as bindgen::codegen::CodeGenerator>::codegen::h5ca489b903d3163d
    18:     0x7ff72307622b - <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen::hcf8d4644130648ec
    19:     0x7ff723076c11 - <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen::h856210ddd994646e
    20:     0x7ff72307644a - <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen::h856210ddd994646e
    21:     0x7ff7230761da - <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen::hcf8d4644130648ec
    22:     0x7ff723080e43 - bindgen::codegen::codegen::{{closure}}::h512e75f104283f43
    23:     0x7ff722fdbd21 - bindgen::ir::context::BindgenContext::gen::h060281cb6c7a3198
    24:     0x7ff723080171 - bindgen::codegen::codegen::h532a35ba1ae06e93
    25:     0x7ff722fea69f - bindgen::deprecated_target_diagnostic::he3809a5d14026bcc
    26:     0x7ff722fe865f - bindgen::Builder::generate::h0222105c071d16cb
    27:     0x7ff722f81b76 - <() as std::process::Termination>::report::h9faf526287b92224
    28:     0x7ff722f824c6 - core::ops::function::FnOnce::call_once::h09a7cff216d73ba5
    29:     0x7ff722f826d9 - std::sys_common::backtrace::__rust_begin_short_backtrace::h8fe0d4a625b4aba0
    30:     0x7ff722f8241c - std::rt::lang_start::{{closure}}::h33bfb89f549285b3
    31:     0x7ff72347966e - core::ops::function::impls::impl$2::call_once
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\core\src\ops\function.rs:287
    32:     0x7ff72347966e - std::panicking::try::do_call
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\panicking.rs:485
    33:     0x7ff72347966e - std::panicking::try
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\panicking.rs:449
    34:     0x7ff72347966e - std::panic::catch_unwind
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\panic.rs:140
    35:     0x7ff72347966e - std::rt::lang_start_internal::closure$2
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\rt.rs:148
    36:     0x7ff72347966e - std::panicking::try::do_call
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\panicking.rs:485
    37:     0x7ff72347966e - std::panicking::try
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\panicking.rs:449
    38:     0x7ff72347966e - std::panic::catch_unwind
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\panic.rs:140
    39:     0x7ff72347966e - std::rt::lang_start_internal
                                 at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\rt.rs:148
    40:     0x7ff722f823f7 - std::rt::lang_start::he210ef9f35c4e739
    41:     0x7ff722f81c39 - main
    42:     0x7ff7234ab050 - invoke_main
                                 at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
    43:     0x7ff7234ab050 - __scrt_common_main_seh
                                 at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    44:     0x7ffedced7614 - BaseThreadInitThunk
    45:     0x7ffedd0a26a1 - RtlUserThreadStart

and/or

// Insert the (incorrect/buggy) generated bindings here

and/or

Insert compilation errors generated when compiling the bindings with rustc here

Expected Results

@pvdrz
Copy link
Contributor

pvdrz commented Jun 25, 2023

cc @reitermarkus

I think this happens because the string already had a null byte and bindgen unconditionally adds another one at the end.

@XVilka
Copy link

XVilka commented Jun 26, 2023

@kouzhudong try downgrading bindgen version to 0.65 - it helped me with a very similar issue: #2566

@kouzhudong
Copy link
Author

same at #2566

0.65.1 is ok
0.66.1 is no ok

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

No branches or pull requests

3 participants