2010-06-29 13:51:08     pthread stack default size

Document created by Aaronwu Employee on Aug 22, 2013
Version 1Show Document
  • View in full screen mode

2010-06-29 13:51:08     pthread stack default size


Message: 90737   




I have been experiencing random crashes within my application and I started to suspect stack overflow.


I have stopped the crashes occurring by starting my pthreads with an attr structure and setting the stack size to 131072, with the following:


pthread_attr_t attr

pthread_attr_init( &attr );

pthread_attr_setstacksize (attr, 131072);

pthread_create( &t, attr, ThreadFunction, pArg );


Out of interest I changed the code so that I use the default information to the attr structure:


pthread_attr_t attr

pthread_attr_init( &attr );

pthread_create( &t, &attr, ThreadFunction, pArg );


This creates a thread stack of 12288.  Where does the 12288 comefrom, or rather where is it defined?


I was thinking that this should be the same as my original thread creation which was like this:


pthread_create( &t, NULL, ThreadFunction, pArg );


However I am starting to think that this produces a different sized stack as I am seeing differnet behaviour, to passing in an attr structure.


Does anyone know where I can find where the stack sizes would be defined, I can find the min stack 1024( which I probably incorrectly assuming to be the default),

a define for a stack of 16384 and a define for 8192. none of them match any of the stack sizes I am seeing!


I am using 2009-R1 dist with xenomai patch applied and custom bf527 hardware, I don't believe I am explicity using the xenomai api, it should all be in linux land.


Thanks in advance for your help.