rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

Thread 'bindgen_test_layout_header' panicked at 'assertion failed: `(left == right)`

Open helloqirun opened this issue 8 years ago • 2 comments

I am using this script (https://gist.github.com/fitzgen/187381e358f60efa8194d0b276b4d11a) for testing. The hashtag for my bindgen version is e841f6f88d13298.

$ ./b.sh bindgen abc.h

clang-4.0: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
abc.h:6:19: warning: unknown attribute 'size' ignored [-Wunknown-attributes]
} __attribute__ ((size, packed));
                  ^
1 warning generated.
abc.h:6:19: warning: unknown attribute 'size' ignored [-Wunknown-attributes], err: false

running 1 test
test bindgen_test_layout_header ... FAILED

failures:

---- bindgen_test_layout_header stdout ----
        thread 'bindgen_test_layout_header' panicked at 'assertion failed: `(left == right)`
  left: `5`,
 right: `8`: Size of: header', /tmp/bindings-hJzMPE.rs:46:4
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:380
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:390
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:611
   5: std::panicking::begin_panic_new
             at /checkout/src/libstd/panicking.rs:553
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:521
   7: bindings_hJzMPE::bindgen_test_layout_header
   8: <F as test::FnBox<T>>::call_box
             at /checkout/src/libtest/lib.rs:1477
             at /checkout/src/libcore/ops/function.rs:143
             at /checkout/src/libtest/lib.rs:138
   9: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98


failures:
    bindgen_test_layout_header

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

Interesting: bindgen emitted type definitions that are failing their
layout unit tests!

$ cat abc.h

struct header
{
  char proto;
  unsigned int size __attribute__ ((packed));
  unsigned char data[] __attribute__ ((aligned (8)));
} __attribute__ ((size, packed));

helloqirun avatar Sep 03 '17 02:09 helloqirun

Thanks for the bug report @helloqirun !

fitzgen avatar Sep 05 '17 16:09 fitzgen

this became:

error[E0587]: type has conflicting packed and align representation hints
  --> /home/christian/Workspace/bindgen/bindgen-tutorial/target/debug/build/bindgen-tutorial-8c47bf657a7ff347/out/bindings.rs:35:1
   |
35 | / pub struct header {
36 | |     pub proto: ::std::os::raw::c_char,
37 | |     pub size: ::std::os::raw::c_uint,
38 | |     pub data: __IncompleteArrayField<::std::os::raw::c_uchar>,
39 | | }
   | |_^

For more information about this error, try `rustc --explain E0587`.
error: could not compile `bindgen-tutorial` due to previous error

pvdrz avatar Sep 19 '22 19:09 pvdrz