中止陷阱:C 程序中的 6 个 [英] Abort trap: 6 in C Program

查看:22
本文介绍了中止陷阱:C 程序中的 6 个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 C 程序.它编译成功并且运行良好,但在 main() 结束时,它崩溃并给我一个 Abort 陷阱:6 错误.

I have a program in C. It compiles successfully and runs works fine but right at the end of main(), it crashes and gives me an Abort trap: 6 error.

我对如何调试它一无所知.关于 SO 与 Abort trap: 6 错误有关的几个问题对我没有多大帮助.

I haven't the slightest clue as to how I can debug this. The few questions on SO having to do with Abort trap: 6 errors have not been of much help to me.

一般来说,可能是什么问题?

In general, what could be the problem?

(我现在不愿意发布我的源代码,因为它大约有 400 行代码.如果我知道要查找什么,我会发布一段特定的代码.)

(I am reluctant to post my source code for now since it is around 400 lines of code. I would post a particular chunk of code if I knew what to look for.)

注意:我在终端中使用 GCC 运行程序.但是当我在 XCode 中运行它时,我的程序崩溃了,如果我停止它,它会以 exit code: 9 结束.

Note: I am running the program in Terminal using GCC. But when I run it in XCode, my program crashes and if I stop it, it ends with exit code: 9.

这是 lldb 的输出:

Process 1191 stopped
* thread #1: tid = 0xa759, 0x00007fff8fa08286 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fff8fa08286 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill + 10:
-> 0x7fff8fa08286:  jae    0x7fff8fa08290            ; __pthread_kill + 20
   0x7fff8fa08288:  movq   %rax, %rdi
   0x7fff8fa0828b:  jmp    0x7fff8fa03c53            ; cerror_nocancel
   0x7fff8fa08290:  retq 

推荐答案

可能写入你不拥有的内存!但是你知道没有代码我们不能说更多,但我明白你为什么不发布它.

You are probably writing to memory you do not own! But you know we can not say more without the code, but I see why you do not post it.

类似问题

我建议再次仔细阅读您的代码,并注意您的计数器和索引(名为 ij 等的变量).

I would suggest reading again your code super-carefully and look out for your counter and indices (variables named i, j and so on).

Exit code 9 闻起来像是信号处理出错了.检查这个问题.

Exit code 9 smells like signal handling going wrong. Check this question.

这篇关于中止陷阱:C 程序中的 6 个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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