Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

macos - Abort trap: 6 in C Program

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 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...