【问题标题】:strange GDB error unable to trace无法追踪的奇怪 GDB 错误
【发布时间】:2010-05-26 07:24:16
【问题描述】:

我在 gdb 中遇到了这个奇怪的错误,我无法跟踪确切的代码行来跟踪错误。有人知道这种类型的错误吗?这是我在 gdb 中得到的内容

*** -[CALayer sublayers]: message sent to deallocated instance 0x911c2a0
(gdb) po 0x911c2a0
Program received signal SIGTRAP, Trace/breakpoint trap.
0x020993a7 in ___forwarding___ ()
The program being debugged was signaled while in a function called from GDB.
GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off"
Evaluation of the expression containing the function (_NSPrintForDebugger) will be   abandoned.
(gdb) info symbol 0x911c2a0
No symbol matches 0x911c2a0.
(gdb) 

【问题讨论】:

    标签: objective-c iphone-sdk-3.0 gdb


    【解决方案1】:

    您可以尝试以下操作以查看故障 CALayer 的分配位置:

    (gdb) info malloc 0x911c2a0
    

    我不知道gdb 是否能很好地处理僵尸对象,但显然,它似乎有一些限制。

    【讨论】:

      【解决方案2】:

      很明显,你有一个内存管理错误。

      而且您根本没有追踪确切的路线。要获取堆栈跟踪,请输入 bt,或直接查看调试器窗口(运行 → 调试器)。

      po 表示“打印 Objective-C 对象”。由于该特定实例已被释放,po-ing 将导致进一步的错误。)

      【讨论】:

        【解决方案3】:

        尝试将NSZombieEnabled 设置为YES 可执行环境进行调试:

        激活 NSZombieEnabled 您的应用程序中的设施:

        选择项目 > 编辑活动 Executable 打开可执行信息 窗户。单击参数。点击添加 “要设置的变量”中的 (+) 按钮 在环境”部分。进入 Name 列中的 NSZombieEnabled 和 是在值列。确保 的复选标记 NSZombieEnabled 条目被选中。

        您可能还想添加几个断点来帮助您调试它们:

        fb -[_NSZombie init]
        fb -[_NSZombie retainCount]
        fb -[_NSZombie retain]
        fb -[_NSZombie release]
        fb -[_NSZombie autorelease]
        fb -[_NSZombie methodSignatureForSelector:]
        fb -[_NSZombie respondsToSelector:]
        fb -[_NSZombie forwardInvocation:]
        fb -[_NSZombie class]
        fb -[_NSZombie dealloc]
        

        【讨论】:

        • 我已经在环境变量中添加了 NSZombieEnabled 并将其设置为 YES。我在哪里添加这些断点? fb -[_NSZombie init] fb -[_NSZombie retainCount]
        • 那些是未来的断点(尚未加载的代码断点)。您可以将它们添加到 ~/.gdbinit。请参阅nslog.de/posts/46 了解我建议放入其中的所有内容的列表。
        【解决方案4】:

        我已经找到了问题的解决方案。问题是由于视图控制器。视图控制器被释放,然后在方法被调用之后。但是奇怪的 gdb 并没有显示任何关于 viewController relese 的信息……打开 NSZombie 也没有帮助。

        【讨论】:

          猜你喜欢
          • 2011-11-05
          • 1970-01-01
          • 1970-01-01
          • 2015-07-04
          • 1970-01-01
          • 1970-01-01
          • 2019-01-12
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多