fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.

Home Page:https://fzyzcjy.github.io/flutter_rust_bridge/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Null pointer dereference (EXC_BAD_ACCESS)

tmpfs opened this issue · comments

commented

Describe the bug

On iOS (in debug mode) I am getting an abort with EXC_BAD_ACCESS, here is the error:

* thread #8, name = 'io.flutter.1.ui', stop reason = EXC_BAD_ACCESS (code=1, address=0x64)
    frame #0: 0x0000000104fb3bfc AppName`_$LT$$BP$mut$u20$sos_native_bindings..api_generated..io..wire_uint_8_list$u20$as$u20$sos_native_bindings..api_generated..Wire2Api$LT$alloc..vec..Vec$LT$u8$GT$$GT$$GT$::wire2api::hf7ba584318230d62 + 16
AppName`_$LT$$BP$mut$u20$sos_native_bindings..api_generated..io..wire_uint_8_list$u20$as$u20$sos_native_bindings..api_generated..Wire2Api$LT$alloc..vec..Vec$LT$u8$GT$$GT$$GT$::wire2api::hf7ba584318230d62:
->  0x104fb3bfc <+16>: ldr    x9, [x0]
    0x104fb3c00 <+20>: ldrsw  x10, [x0, #0x8]
    0x104fb3c04 <+24>: stp    x9, x10, [x8]
    0x104fb3c08 <+28>: str    x10, [x8, #0x10]
Target 0: (AppName) stopped.

Any suggestions on how to debug this crash please?

Steps to reproduce

Sorry, don't have an MVP to reproduce this.

Logs

N/A

Expected behavior

Does not crash.

Generated binding code

No response

OS

iOS

Version of flutter_rust_bridge_codegen

1.82.6

Flutter info

No response

Version of clang++

No response

Additional context

No response

commented

Using ffigen v8 FWIW.

commented

Looking through the crash log points to this in api_generated.io.rs:

impl Wire2Api<Vec<u8>> for *mut wire_uint_8_list {
    fn wire2api(self) -> Vec<u8> {
        unsafe {
            let wrap = support::box_from_leak_ptr(self);
            support::vec_from_leak_ptr(wrap.ptr, wrap.len)
        }
    }
}
commented

Huh, upgraded Flutter from 3.13.2 to 3.16.9 and it's fixed.

Happy to see it is fixed! If you have a minimal reproducible sample, feel free to post and happy to check what is going wrong.

By the way, you can use the SSE codec as well (currently the generated code seems to be DCO codec) as a workaround if you ever have this problem later.