native
native copied to clipboard
[ffigen] Nicer error messages when ObjC Blocks are invoked after deletion.
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.