调用 method_getImplementation 在设备上抛出 ExecutionEngineException
Calling method_getImplementation throws ExecutionEngineException on device
我正在尝试根据问题 here. I have a example on github. The full crash is here 的答案实施调配。
[DllImport("/usr/lib/libobjc.dylib")]
extern static Func<IntPtr,IntPtr,IntPtr> method_getImplementation(IntPtr method);
delegate void CaptureDelegate(IntPtr block,IntPtr self,IntPtr uiView);
[MonoPInvokeCallback(typeof(CaptureDelegate))]
static void MyCapture(IntPtr block, IntPtr self, IntPtr uiView)
{
}
static void HijackWillMoveToSuperView()
{
var method = class_getInstanceMethod(new UIView().ClassHandle, new Selector("willMoveToSuperview:").Handle);
original_impl = method_getImplementation(method);
var block_value = new BlockLiteral();
CaptureDelegate d = MyCapture;
block_value.SetupBlock(d, null);
var imp = imp_implementationWithBlock(ref block_value);
method_setImplementation(method, imp);
}
该示例适用于模拟器,但不适用于设备。在设备上,
original_impl = method_getImplementation(method);
抛出一个 ExecutionEngineException
Attempting to JIT compile method '(wrapper managed-to-native)
System.Func`3:wrapper_aot_native
(intptr&,intptr,intptr)' while running with --aot-only.
我需要做什么才能进行 AOT 编译?或者,这是在 ARM64 上调用 method_getImplementation(method) 的问题吗?我找到了一些关于 here.
的信息
It seems like using an imp_implementationWithBlock crashes on arm64.
还有更多here:
Note the cast to objc_msgSend. While this (by luck) worked without
casting in the earlier days, this will probably crash your arm64 build
if you don’t cast this correctly, because the variable argument
casting specifications changed.
objective-chere中有一个示例,其中检查了体系结构并且 32 和 64 的行为不同。我想知道我是否有同样的问题。
return 值是 "IntPtr",而不是 "Func"。
我正在尝试根据问题 here. I have a example on github. The full crash is here 的答案实施调配。
[DllImport("/usr/lib/libobjc.dylib")]
extern static Func<IntPtr,IntPtr,IntPtr> method_getImplementation(IntPtr method);
delegate void CaptureDelegate(IntPtr block,IntPtr self,IntPtr uiView);
[MonoPInvokeCallback(typeof(CaptureDelegate))]
static void MyCapture(IntPtr block, IntPtr self, IntPtr uiView)
{
}
static void HijackWillMoveToSuperView()
{
var method = class_getInstanceMethod(new UIView().ClassHandle, new Selector("willMoveToSuperview:").Handle);
original_impl = method_getImplementation(method);
var block_value = new BlockLiteral();
CaptureDelegate d = MyCapture;
block_value.SetupBlock(d, null);
var imp = imp_implementationWithBlock(ref block_value);
method_setImplementation(method, imp);
}
该示例适用于模拟器,但不适用于设备。在设备上,
original_impl = method_getImplementation(method);
抛出一个 ExecutionEngineException
Attempting to JIT compile method '(wrapper managed-to-native) System.Func`3:wrapper_aot_native (intptr&,intptr,intptr)' while running with --aot-only.
我需要做什么才能进行 AOT 编译?或者,这是在 ARM64 上调用 method_getImplementation(method) 的问题吗?我找到了一些关于 here.
的信息It seems like using an imp_implementationWithBlock crashes on arm64.
还有更多here:
Note the cast to objc_msgSend. While this (by luck) worked without casting in the earlier days, this will probably crash your arm64 build if you don’t cast this correctly, because the variable argument casting specifications changed.
objective-chere中有一个示例,其中检查了体系结构并且 32 和 64 的行为不同。我想知道我是否有同样的问题。
return 值是 "IntPtr",而不是 "Func"。