`extern __mfp8` stack-overflows while parsing the variable (function form becomes `u8`)

Open
#3,470 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c, cpp, rust
Domain
compilers, tooling

Research direction

Reproduce the issue with bindgen on the listed __mfp8 variable and function declarations, then trace variable parsing alongside the build_builtin_ty path mentioned in the report. Done means variable declarations no longer recurse or abort, while the existing function-form fallback remains intact; verify the reported headers and array case.

Written by the indexing model from the issue text.

Description

Input C/C++ Header
extern __mfp8 G;
Bindgen Invocation
$ bindgen input.h
Actual Results

bindgen never produces bindings. On Darwin it dies with EXC_BAD_ACCESS (shell status 139) after overflowing the stack. lldb stops in HashMap<ItemId, ()>::insert with a stack address, which is the usual signature of unbounded recursion while parsing the type.

The same abort happens for __mfp8 G;, static __mfp8 G;, const __mfp8 G;, and extern const __mfp8 G;. extern __mfp8 A[4]; hangs until killed (same recursion, slower).

A function using the same type does not abort. It goes through the opaque-size fallback:

__mfp8 take(__mfp8 a);
unsafe extern "C" { pub fn take(a: u8) -> u8; }

__mfp8 is clang's ACLE 8-bit float builtin. libclang presents a builtin type that is not in build_builtin_ty. Function/field/pointer/typedef forms therefore become u8. Variable declarations recurse instead of taking that fallback.

Reproduced with bindgen 0.72.1 and 0.73.1.

Expected Results

Do not recurse or abort. Skip the variable, or use the same size-based fallback already used for __mfp8 parameters (u8), ideally without claiming a real 8-bit float ABI.

Environment
bindgen: 0.72.1 and 0.73.1 (rust-lang/rust-bindgen 77cbc723)
clang/libclang: Homebrew clang 21.1.8
rustc: 1.97.1
target: aarch64-apple-darwin
OS: macOS
Dominant language
Rust
Stars
5.3k
Forks
846
Avg merge
2d 6h
Merged PRs (30d)
11

Getting set up

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.

More from rust-lang/rust-bindgen

All issues in rust-lang/rust-bindgen

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.