Skip to content

mixing header and header_contents always panics #1771

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

Closed
YruamaLairba opened this issue May 1, 2020 · 5 comments
Closed

mixing header and header_contents always panics #1771

YruamaLairba opened this issue May 1, 2020 · 5 comments

Comments

@YruamaLairba
Copy link

Hi, i'm unable to use header(...) and header_contents(...) for the same bindings generation, libclang always panics.

Input C/C++ Header

Header content doesn't matter, it even happen when headers are empty.

Bindgen Invocation

fn main() {
    bindgen::builder()
        .header("bar.h")
        .header_contents("foo.h", "")
        .generate()
        .expect("Unable to generate bindings");
}

Actual Results

thread 'main' panicked at 'libclang error; possible causes include:
- Invalid flag syntax
- Unrecognized flags
- Invalid flag arguments
- File I/O errors
- Host vs. target architecture mismatch
If you encounter an error missing from this list, please file an issue or a PR!', /home/amaury/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.2/src/ir/context.rs:567:13
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1052
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:472
  11: rust_begin_unwind
             at src/libstd/panicking.rs:380
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
  13: core::option::expect_failed
             at src/libcore/option.rs:1191
  14: core::option::Option<T>::expect
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/libcore/option.rs:347
  15: bindgen::ir::context::BindgenContext::new
             at /home/amaury/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.2/src/ir/context.rs:567
  16: bindgen::Bindings::generate
             at /home/amaury/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.2/src/lib.rs:2106
  17: bindgen::Builder::generate
             at /home/amaury/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.2/src/lib.rs:1419
  18: header_contents::main
             at src/main.rs:2
  19: std::rt::lang_start::{{closure}}
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/libstd/rt.rs:67
  20: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
  21: std::panicking::try::do_call
             at src/libstd/panicking.rs:305
  22: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:86
  23: std::panicking::try
             at src/libstd/panicking.rs:281
  24: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  25: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  26: std::rt::lang_start
             at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/libstd/rt.rs:67
  27: main
  28: __libc_start_main
  29: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Expected Results

I just expected a bindings result, not a panic.

@emilio
Copy link
Contributor

emilio commented May 4, 2020

Thanks for reporting! I think this is likely a silly error in how we build the argument list in combination of these two options, and should be easy to figure out what is going on.

@curldivergence
Copy link

Hey @emilio, I've updated my previous commit and added a couple of tests, it seems there are no regressions this time.

@Dessix
Copy link

Dessix commented Jan 10, 2021

Is there anything still blocking merge of this PR? I ended up taking a dependency on this and can't cargo-publish with a dependency on an unofficial fork.

@emilio
Copy link
Contributor

emilio commented Jan 10, 2021

Yes, CI was failing, and there was some discussion about some test changes that didn't happen.

Guess we can take the test as is, and I can fix the CI failures.

@emilio emilio closed this as completed in 5177889 Jan 10, 2021
@Dessix
Copy link

Dessix commented Jan 11, 2021

@emilio Can we get a patch release with this change integrated?

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