使用 64 位 arm64 构建时 obj_msgSend 函数指针崩溃 [英] obj_msgSend function pointer crash when build with 64bit arm64

查看:53
本文介绍了使用 64 位 arm64 构建时 obj_msgSend 函数指针崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上,我的原始代码在 Xcode 5.0.2 上运行良好,也非常适合发送到 App Store:

Actually my original code works great with Xcode 5.0.2 and also great for sending to App Store which is:

objc_msgSend(self.target, self.successAction, category);

此行导致 Xcode5.1 beta5 崩溃.我找到了解决崩溃的解决方案:SudzC ARC 版本 -objc_msgSend 调用导致 EXC_BAD_ACCESS 使用 64 位架构

This line causes crashes with Xcode5.1 beta5. I found a solution to fix the crash: SudzC ARC version - objc_msgSend call causes EXC_BAD_ACCESS using 64-bit architecture

// solution
id (*response)(id, SEL, id) = (id (*)(id, SEL, id)) objc_msgSend;
response(self.target, self.successAction, category);

当使用推荐的解决方案时,我使用 Xcode 5 或 Xcode5.1beta 在设备(iPhone 5s)或模拟器(32 位或 64 位)上进行测试完全没有问题.Build Settings 中的 architectures 设置为 Xcode 5 中的Standard architectures (armv7, armv7s)"和Standard architectures (armv7, armv7s, arm64)".

And I get no problem at all either using Xcode 5 or Xcode5.1beta to test on devices(iPhone 5s) or simulator(32bit or 64bit) when using the recommended solution. The architectures setting in Build Settings is "Standard architectures (armv7, armv7s)" in Xcode 5 and "Standard architectures (armv7, armv7s, arm64)".

不过,我的新版应用今天已经准备好在 App Store 上架了.它在安装的每个设备(iPhone 5s、5、4s)上崩溃(根据 Crashlytics 报告).由于我没有使用 Xcode(构建到真实设备)发生崩溃,因此在 Apple 审核之前我不知道我是否解决了问题.

However, my new version of app is ready for sale on App Store today. And it crashes on every devices(iPhone 5s, 5, 4s) installed (according to Crashlytics report). Since I don't get the crash using Xcode(build to real device), I don't know if I fix the problem or not before reviewed by Apple.

推荐答案

最后,我现在可以重现崩溃.只需编辑 Build Scheme 并将Run YOURAPPNAME.app"从 Debug 更改为 Release.

Finally, I can reproduce the crash right now. Simply edit Build Scheme and change "Run YOURAPPNAME.app" from Debug to Release.

在我可以重现这个错误之后,我知道如何修复它.由于我的选择器函数类型是 void(不返回任何内容),我不应该只是复制问题的作用(使用id").

And right after I can reproduce this bug, I know how to fix it. Since my selector function type is void(does not return anything), I should not just copy what the question does (using "id").

通过改变:

id (*response)(id, SEL, id) = (id (*)(id, SEL, id)) objc_msgSend;
response(self.target, self.successAction, category);

致:

void (*response)(id, SEL, id) = (void (*)(id, SEL, id)) objc_msgSend;
response(self.target, self.successAction, category);

修复了!!或者感谢 github 上的这个提交:

It fixes!! Or a one-line code thanks to this commit on github:

((void(*)(id, SEL, id))objc_msgSend)(self.target, self.successAction, category);

这篇关于使用 64 位 arm64 构建时 obj_msgSend 函数指针崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆