rust-lang / rust-lang/rust-bindgen

SIGSEGV running rust-bindgen on Objective-C headers

Open
#665 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug I-panic
Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Input C/C++ Objective-C Header
#import <Foundation/Foundation.h>
#import <NSWindow.h>
#import <NSTableView.h>
Bindgen Invocation
    let sdk_root = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk";

    let bindings = bindgen::Builder::default()
        .no_unstable_rust()
        .objc_extern_crate(true)
        .clang_arg("-x")
        .clang_arg("objective-c")
        .clang_arg(format!("-isysroot{}", sdk_root))
        .clang_arg("-mmacosx-version-min=10.10")
        .header("src/wrapper.h")
        .generate()
        .expect("Unable to generate bindings");

Invoked via cargo build with RUST_LOG=libbindgen and RUST_BACKTRACE=1.

Actual Results
oluseyi@Metroplex ~/S/cocoabind-rs> env RUST_LOG=libbindgen RUST_BACKTRACE=1 cargo build
   Compiling cocoabind-rs v0.1.0 (file:///Users/oluseyi/Source/cocoabind-rs)
error: failed to run custom build command for `cocoabind-rs v0.1.0 (file:///Users/oluseyi/Source/cocoabind-rs)`
process didn't exit successfully: `/Users/oluseyi/Source/cocoabind-rs/target/debug/build/cocoabind-rs-b444d464ed631d7a/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)

Note: No stack trace generated!

Expected Results

At this point, simply successful execution without segfault and generation of bindings, even if incorrect.

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

Start by reproducing the failure with the shown Objective-C imports, bindgen invocation, and cargo build environment using RUST_LOG=libbindgen and RUST_BACKTRACE=1. Investigate the crash while processing src/wrapper.h and the referenced macOS SDK headers; done means cargo build completes without SIGSEGV and generates bindings.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.