iPhone 应用程序仅在 3G 发布模式下崩溃

发布于 2024-10-02 07:40:24 字数 1469 浏览 10 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

南风几经秋 2024-10-09 07:40:25

你说“我的对象没有被我的任何代码释放”。我发现在 Objective-C 中,遇到代码没有显式释放对象但对象已经被释放的情况并不少见。例如,在我的脑海中,假设您有一个对象 #1,其保留计数为 1,您释放了它,但随后意外地自动释放了它。然后,在自动释放池实际耗尽之前,您分配一个新对象#2——这个新对象#2 可以分配在与对象#1 相同的地址,这并非不可想象。因此,当自动释放池随后被耗尽时,它会意外释放对象#2。

You say "My object is not released by any of my code". I've found that it's not uncommon in Objective-C to run into situations where your code has not explicitly released an object yet the object has been released all the same. For example, off the top of my head, let's say that you have an object #1 with retain count of 1 and you release it but then autorelease it accidentally. Then, before the autorelease pool is actually drained, you allocate a new object #2 -- it's not inconceivable that this new object #2 could be allocated at the same address as object #1. So when the autorelease pool is subsequently drained, it will release object #2 accidentally.

等你爱我 2024-10-09 07:40:24

我最近遇到了完全相同的问题,但我不完全确定原因是相同的。我可以告诉你的是,是什么为我解决了这个问题(尽管我仍然对解决方案并不完全满意)。

最后,这似乎是一个编译器问题,这可能证实了其他人关于编译器优化的说法。
我正在使用 Xcode 4.0(内部版本 4A304a)。问题出在 LLVM 编译器 2.0 代码生成上。特别是一个关键:“优化级别”

调试被设置为“无”。
发布设置为“最快,最小”,

将发布更改为“无”修复了崩溃(同样,将调试更改为“最快,最小”导致应用程序在启动时崩溃)。

I had the exact same problem recently, however I am not entirely sure the cause is the same. What I can tell you though is what resolved the issue for me (although I'm still not entirely satisfied with the solution).

In the end, it seems like a compiler issue, and this might confirm what others have said about compiler optimization.
I am using Xcode 4.0 (build 4A304a). The issue was with LLVM compiler 2.0 Code Generation. One key in particular: "Optimization Level"

Debug was set to "None".
Release was set to "Fastest, Smallest"

Changing Release to "None" fixed the crash (and similarly changing Debug to "Fastest, Smallest" caused the app the crash on launch).

日暮斜阳 2024-10-09 07:40:24

我建议您使用 NSZombieEnabled 来了解什么是导致内存访问错误。

  • 您是否使用 DEBUG / RELEASE 定义来分支代码?
  • 您是否使用 SDK 版本检查器来分支代码?

否则我无法看到您的应用程序在不同设备/配置上的行为有何不同。

I recommend you to use NSZombieEnabled to find out what is causing a bad access to memory.

  • Do you use DEBUG / RELEASE defines to branch your code?
  • Do you use SDK version checkers to branch your code?

Otherwise I can't see how your app can behave diferently on different devices/configurations.

剩余の解释 2024-10-09 07:40:24

我可以建议将发布设置的优化级别更改为“无”。
我多次遇到同样的问题(使用不同的应用程序)并以这种方式解决。

I can propose to change optimization level of release settings to "None".
I met the same problem few times (with different apps) and solved it in this way.

尘世孤行 2024-10-09 07:40:24

我从未“解决”这个问题,但我确实找到了有问题的代码。我怀疑这一段 Quartz 代码中的某些内容导致了内核深处某处的缓冲区溢出 - 并且它只在 3G 上引起了问题。该部分的一些设置未包括在内,但这绝对是它发生的地方:

gradient = CGGradientCreateWithColors(space, (CFArrayRef)colors, locations);
CGContextAddPath(context, path);
CGContextSaveGState(context);
CGContextEOClip(context);
transform = CGAffineTransformMakeRotation(1.571f);
tempPath = CGPathCreateMutable();
CGPathAddPath(tempPath, &transform, path);
pathBounds = CGPathGetPathBoundingBox(tempPath);
point = pathBounds.origin;
point2 = CGPointMake(CGRectGetMaxX(pathBounds), CGRectGetMinY(pathBounds));
transform = CGAffineTransformInvert(transform);
point = CGPointApplyAffineTransform(point, transform);
point2 = CGPointApplyAffineTransform(point2, transform);
CGPathRelease(tempPath);
CGContextDrawLinearGradient(context, gradient, point, point2, (kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation));
CGContextRestoreGState(context);
CGGradientRelease(gradient);

I never "solved" this but I did track down the offending code. I suspect that something in this segment of Quartz code was causing a buffer overrun somewhere deep inside the core - and it only caused a problem on 3G. Some of the setup for this segment is not included but this is definitely where it is happening:

gradient = CGGradientCreateWithColors(space, (CFArrayRef)colors, locations);
CGContextAddPath(context, path);
CGContextSaveGState(context);
CGContextEOClip(context);
transform = CGAffineTransformMakeRotation(1.571f);
tempPath = CGPathCreateMutable();
CGPathAddPath(tempPath, &transform, path);
pathBounds = CGPathGetPathBoundingBox(tempPath);
point = pathBounds.origin;
point2 = CGPointMake(CGRectGetMaxX(pathBounds), CGRectGetMinY(pathBounds));
transform = CGAffineTransformInvert(transform);
point = CGPointApplyAffineTransform(point, transform);
point2 = CGPointApplyAffineTransform(point2, transform);
CGPathRelease(tempPath);
CGContextDrawLinearGradient(context, gradient, point, point2, (kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation));
CGContextRestoreGState(context);
CGGradientRelease(gradient);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文