rust-lang / rust-lang/rust-bindgen

Panic with 'Unable to get layout information?'

Open
#1,768 10 comments 0 reactions 0 assignees View on GitHub

@Danielmelody is already working on this.

Since Feb 23, 2023.

  • #2423 by @Danielmelody — open
A-C++ A-templates bug help wanted
Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

I'm trying to create a wrapper around OpenVDB C++ library. OpenVDB is a volume data file format used in blockbuster visual effects.

There is a repo with instructions to replicate on macOS. The panic happens pretty late during binding generation.

Bindgen Invocation
    let openvdb_bindings = bindgen::Builder::default()
        .header("wrapper.hpp")
        .clang_arg("-std=c++11")
        .clang_arg(format!("-I/{}", open_vdb.join("include").display()))
        .clang_arg("-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Versions/A/Headers/")
        .clang_arg("-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Headers/")
        .clang_arg("-I/Library/Developer/CommandLineTools/usr/include/c++/v1/")
        .clang_arg("-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/")
        .clang_arg("-F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/")
        .generate()
        .expect("Unable to generate OpenVDB bindings.");
Actual Results
thread 'main' panicked at 'Unable to get layout information?', /Users/moritz/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.2/src/codegen/mod.rs:1682:26
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::option::expect_failed
   9: core::option::Option<T>::expect
  10: <bindgen::ir::comp::CompInfo as bindgen::codegen::CodeGenerator>::codegen
  11: <bindgen::ir::ty::Type as bindgen::codegen::CodeGenerator>::codegen
  12: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
  13: <bindgen::ir::comp::CompInfo as bindgen::codegen::CodeGenerator>::codegen
  14: <bindgen::ir::ty::Type as bindgen::codegen::CodeGenerator>::codegen
  15: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
  16: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen::{{closure}}
  17: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen
  18: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
  19: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen::{{closure}}
  20: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen
  21: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
  22: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen::{{closure}}
  23: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen
  24: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
  25: bindgen::codegen::codegen::{{closure}}
  26: bindgen::ir::context::BindgenContext::gen
  27: bindgen::codegen::codegen
  28: bindgen::Bindings::generate
  29: bindgen::Builder::generate
  30: build_script_build::main
  31: std::rt::lang_start::{{closure}}
  32: std::rt::lang_start_internal
  33: std::rt::lang_start
  34: main

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the panic on macOS using the openvdb-sys instructions and the shown bindgen invocation. Start at bindgen-0.53.2/src/codegen/mod.rs:1682 and compare the behavior with linked pull request #2423. Done means binding generation no longer panics for this OpenVDB case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, macos, rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.