iOS5下的memset'CortexA8'问题

时间:2012-01-10 08:31:38

标签: ios5 crash-reports memset plcrashreporter llvm-3.0

自从iOS5上街后,我开始收到很多(很多)崩溃报告,如:

...
Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0x0
Crashed Thread:  0

Thread 0 Crashed:
0   libsystem_c.dylib  0x35ec4b3c memset$VARIANT$CortexA8 + 116
1   FooApp             0x0005ba25 -[FooViewController prepareShapes] (FooViewController.m:808)
...

相关细节:

  • XCode 4.2
  • LLVM 3.0
  • 'armv6 armv7'架构
  • iOS 5基础SDK
  • 定位iOS 4.0
  • 仅在iOS5下崩溃(所有iOS5 iPhone型号。没有iPad崩溃,但应用程序不通用)
  • 无法在我的任何设备上重现崩溃(当然)

现在[FooViewController prepareShapes]不直接调用memset,而是将结构(表示形状)传递给尝试重新分配它的类方法。堆栈跟踪跳过类方法的事实有点奇怪但毫无疑问它是更多的编译器魔法,我不明白。在类方法中,调用memset的块如下:

// class method invoked by [FooViewController prepareShapes]:808 (shape is coloured2DShape instance) 
shape->maxVertexCount = maxVertexes;
if (shape->maxVertexBytes != 0)
{
    free(shape->vertices);
}
shape->maxVertexBytes = sizeof(vertex_2D_4byteColour) * shape->maxVertexCount;
shape->vertices = (vertex_2D_4byteColour *)malloc(shape->maxVertexBytes);
memset(shape->vertices, 0, shape->maxVertexBytes);

这是被操纵的结构

// coloured2DShape struct
typedef struct coloured2DShape
{
    vertex_2D_4byteColour* vertices;
    GLushort* indices;
    uint maxVertexBytes;
    uint maxIndexBytes;
    int vertexCount;
    int indexCount;
    int maxVertexCount;
    int maxIndexCount;
} coloured2DShape;

我认识到这并不是建议使用OpenGL的方式,但真正让我感到困惑的事情(我在这里真的很棒)memset只会在iOS5下爆炸(我正在使用QuincyKit来收集崩溃报告,并使用HockeyApp来汇总它们。这个确切的代码已经在iOS4(用GCC编译)下进行了几个月。

我希望这不会被解释为“做我的功课”。我花了几个月的时间研究,调整(我已经发布了几个解决这个问题的更新)和没有进展的头发拉动。我完全没有想法。

2 个答案:

答案 0 :(得分:1)

我认为memset工作正常,但对malloc的调用因某种原因失败,返回0

答案 1 :(得分:0)

我要发布一小段调试后发现的类似崩溃的消息,也许对某人有用...... 原因是如此愚蠢的事情。 我在NSLog中有两个占位符,只有一个实变量。

NSLog(@"lastItemDate = %@ unixtime = %@", lastItemDate);