Abort trap: 6 in C Program

做~自己de王妃 提交于 2019-11-28 08:36:18

问题


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.

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?

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

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.

This is the output from 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 

回答1:


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.

Similar question

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 smells like signal handling going wrong. Check this question.



来源:https://stackoverflow.com/questions/29401116/abort-trap-6-in-c-program

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!