tags:

views:

28

answers:

1
+6  A: 

It would appear you're overflowing the stack.

You'll need to either turn the long array into a malloced one, or use pthread_attr_setstacksize and friends to create a larger stack when you call pthread_create.

Default thread stack sizes vary a lot before platforms, which would explain why the code works on other platforms.

https://computing.llnl.gov/tutorials/pthreads/#Stack has some example code.

As to why you get a sigbus, it's probably because the act of creating the array is overwriting some part of pthreads internal data structures with garbage, resulting in an alignment error when pthreads tries to clean up the thread.

JosephH
Thanks, that makes sense, using getstacksize() I'm being told that the thread has 524288 bytes of stack, assuming long is 8 bytes, 8*62435 comes to just under that (523480), I would imagine the rest is overhead of some sort?
lochii
sounds likely. There'll be a pthread block at the bottom of the thread and there'll be a small overhead from any functions on the callstack.
JosephH