rust-lang / rust-lang/rust-bindgen
The bindgen generated incorrect function signature for the C++ member function.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
bindgen would generate the incorrect binding for the C++ member function Dims getBindingDimensions(int32_t bindingIndex) const;. It would generate:
extern "C" {
#[link_name = "\u{1}?getBindingDimensions@ICudaEngine@nvinfer1@@QEBA?AVDims32@2@H@Z"]
pub fn ICudaEngine_getBindingDimensions(
this: *const root::nvinfer1::ICudaEngine,
bindingIndex: i32,
) -> root::nvinfer1::Dims;
}
// mov rdx, [rbp+0A10h+var_7D8.raw] ; the raw is this pointer
// lea rcx, [rbp+0A10h+var_6C8] ; return value Dims
// mov r8d, 457h ; bindingIndex
// call ?getBindingDimensions@ICudaEngine@nvinfer1@@QEBA?AVDims32@2@H@Z ;
Clearly, this result is incorrect as the this pointer will be passed through rdx (The this pointer should be passed through rcx).
This will result in a segmentation fault.
In C++ complie correct result:
Dims getBindingDimensions(int32_t bindingIndex) const;
...
mov [rsp+arg_10], r8d ; bindingIndex
mov [rsp+arg_8], rdx ; return value
mov [rsp+arg_0], rcx ; this pointer
...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the generated binding for Dims getBindingDimensions(int32_t bindingIndex) const; and inspect bindgen's C++ member-function ABI handling. Compare the generated call convention with the shown correct C++ result; done means the this pointer is passed through the correct register and the binding no longer causes a segmentation fault.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100