Solving Bus Error: 10 crash on OSX



This note is mostly a reminder to myself but could be useful to others.

While running some CSV parsing code on OSX, I encountered a crash that took me a long time to debug. All I got when the crash happened was a Bus Error: 10 as soon as the program jumped into a text parsing function I wrote. Bus Error: 10 is a typical error appearing when undefined pointers are dereferenced, but this wasn't what was happening in my case: No code from the function was executed: the crash seemed to happen right at function start

I was finally able to figure out the problem was with local array declarations, in particular an array whose size was about 256k. Since this array was declared within the function scope, it ended up being allocated on the stack, and the stack would end up overflowing because of this. Moving this array to the heap solved the problem for me.

Comments

Popular posts from this blog

Parallel Beam Tracing and Visualization of 200 Million Sonar Points

Parallel Gaussian Elimination Using MPI

Flickering 2D transform elements in Chrome: a simple fix