Skip to content

[ffigen] Nicer error messages when ObjC Blocks are invoked after deletion. #200

Open
@liamappelbe

Description

Currently if an ObjC block is invoked by native code after it has been deleted, we get a null assertion failure here, because block.ref.target.address is some junk value:

void _ObjCBlock_ffiVoid_CMPedometerData_NSError_closureTrampoline(
        ffi.Pointer<_ObjCBlock> block,
        ffi.Pointer<ObjCObject> arg0,
        ffi.Pointer<ObjCObject> arg1) =>
    _ObjCBlock_ffiVoid_CMPedometerData_NSError_closureRegistry[
        block.ref.target.address]!(arg0, arg1);
//                               ^ NPE here

Instead we should throw an exception with an error message explaining that this is probably caused by the block having been deleted.

Metadata

Assignees

No one assigned

    Labels

    good first issueA good starting issue for contributors (issues with this label will appear in /contribute)package:ffigen

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions