C语言 中止陷阱:C 程序中的 6

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29401116/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 11:49:04  来源:igfitidea点击:

Abort trap: 6 in C Program

cmacosgcccrashabort

提问by aanrv

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: 6error.

我有一个程序C.它成功地编译和运行工作正常,但就在年底main(),它崩溃并给了我一个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: 6errors have not been of much help to me.

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

In general, what could be the problem?

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

(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.)

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

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.

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

This is the output from lldb:

这是来自的输出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 

采纳答案by gsamaras

You are probablywriting 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.

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

Similar question

类似问题

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

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



Exit code 9smells like signal handling going wrong. Check thisquestion.

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