Skip to content

[ffi] Data corruption from native thread #59635

@LeoBound

Description

@LeoBound

Hi,
I'm having an issue where a NativeCallable.listener callback is receiving garbled data.
My callback is void Function(Pointer<Char> json) => json.cast<Utf8>().toDartString();
This fails ~80% of the time as it fails to decode the UTF-8 in the call to toDartString(). This string should always be valid UTF-8, and indeed in the remaining 20% of the time it succeeds and behaves as expected.

I believe it is similar to the issue described here.

Is there a workaround for this? I think the proposed NativeCallable.blocking might solve it but in the meantime is there anything I can do from the dart side?

Dart SDK version: 3.4.4

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-native-interopUsed for native interop related issues, including FFI.triage-automationSee https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions