native icon indicating copy to clipboard operation
native copied to clipboard

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

Open liamappelbe opened this issue 2 years ago • 0 comments

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.

liamappelbe avatar Nov 15 '23 04:11 liamappelbe