-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
Bug Report
Description
The generated RustBuffer struct in cpp/includes/RustBuffer.h uses size_t for the capacity and len fields, but UniFFI's C ABI specification requires uint64_t on all platforms. This causes a critical ABI mismatch on 32-bit ARM architectures.
Platforms Affected
- ❌ 32-bit ARM (armeabi-v7a): Crashes immediately during argument marshalling
- ✅ 64-bit platforms: Works by accident (size_t == uint64_t == 8 bytes)
Reproduction
- Build a React Native app using uniffi-bindgen-react-native on a 32-bit ARM device (e.g., Amazon Fire TV, armeabi-v7a)
- Call any UniFFI function that accepts a
RustBufferparameter - App crashes with SIGSEGV before any Rust code executes
Crash Details
Process: <app>, PID: <pid>
Signal: SIGSEGV (Segmentation fault)
#00 pc <addr> <lib>.so (NativeModule::cpp_uniffi_<crate>_fn_constructor_<type>_new+102)
The crash occurs in the C++ JSI wrapper during constructor marshalling. The stack/register corruption happens because:
- C++ passes
RustBufferwith 4-bytesize_tfields on 32-bit ARM - Rust expects
RustBufferwith 8-byteu64fields per UniFFI spec
Root Cause
The RustBuffer struct definition doesn't match UniFFI's ABI:
// Current (incorrect) - cpp/includes/RustBuffer.h
struct RustBuffer {
size_t capacity; // 4 bytes on 32-bit ARM, 8 bytes on 64-bit
size_t len; // 4 bytes on 32-bit ARM, 8 bytes on 64-bit
uint8_t *data;
};UniFFI's ABI specification mandates uint64_t (8 bytes) on ALL platforms:
Fix
Change size_t to uint64_t to match UniFFI's ABI across all platforms.
PR submitted: #313
Environment
- Device: Amazon Fire TV (armeabi-v7a)
- Framework: Expo SDK 54 / React Native 0.81
- uniffi-bindgen-react-native: latest from main branch
References
- UniFFI RustBuffer ABI: https://mozilla.github.io/uniffi-rs/0.27/internals/api/uniffi/struct.RustBuffer.html
- Related UniFFI issue:
RustBufferByReferencemisreports its size mozilla/uniffi-rs#2681
Metadata
Metadata
Assignees
Labels
No labels