Unix stack size pthread_create

I am creating 10 threads using pthread_create in my application. What is the default stack size assigned to each thread?

I am trying to debug a crash when my application crashes on an illegal instruction where one of the function pointers reset is 0. One indicator of this could be my application thread running out of stack size and overwriting the existing stack space that the function pointer was in.

+3


source to share


1 answer


See https://computing.llnl.gov/tutorials/pthreads/ for a tutorial on pthreads. You are setting the size of the initial stack with a parameter attr

created with pthread_attr_init

. In general, you don't want to have a huge stack. If you are allocating more than a hundred hundred hundred kilobytes on the stack, it may be easier for you to debug your program by allocating data on the heap and freeing it as needed.



+1


source







All Articles