title: Abort trap: 6 in C Program
body: <p>I have a program in C. It compiles successfully and runs works fine but right at the end of <code>main()</code>, it crashes and gives me an <code>Abort trap: 6</code> error.</p>
  
  <p>I haven't the slightest clue as to how I can debug this.  The few questions on SO having to do with <code>Abort trap: 6</code> errors have not been of much help to me.</p>
  
  <p>In general, what could be the problem?</p>
  
  <p>(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.)</p>
  
  <p>Note: I am running the program in Terminal using <code>GCC</code>. But when I run it in XCode, my program crashes and if I stop it, it ends with <code>exit code: 9</code>.</p>
  
  <p>This is the output from <code>lldb</code>:</p>
  
  <pre><code>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:
  -&gt; 0x7fff8fa08286:  jae    0x7fff8fa08290            ; __pthread_kill + 20
     0x7fff8fa08288:  movq   %rax, %rdi
     0x7fff8fa0828b:  jmp    0x7fff8fa03c53            ; cerror_nocancel
     0x7fff8fa08290:  retq 
  </code></pre>