Discussion:
pthread stack size on HPUX 11.00 and 11.11
(too old to reply)
Aditya Kulkarni
2004-02-02 09:17:16 UTC
Permalink
Hi all,

I am developing an application which is linked with a shared library.
My piece of code runs inside a pthread using default stack size of
64KB.
I am calling a function inside the library. Unfortunately, the
function defines a 64KB automatic variable. Since the default stack
size on HPUX 11.00, 11.11 is 64KB, the stack gets overrun, and I get a
core dump.

Limitations that I am facing:
[1] The shared library which I link is shipped by someone else, who is
not in my organisation.

[2] The thread in which my piece of code runs, is created by someone
else, so I cant increase the stack size of the thread.

So, whats the solution ?

Thanks
Aditya Kulkarni
Rémy
2004-02-02 09:45:11 UTC
Permalink
Post by Aditya Kulkarni
Hi all,
I am developing an application which is linked with a shared library.
My piece of code runs inside a pthread using default stack size of
64KB.
I am calling a function inside the library. Unfortunately, the
function defines a 64KB automatic variable. Since the default stack
size on HPUX 11.00, 11.11 is 64KB, the stack gets overrun, and I get a
core dump.
[1] The shared library which I link is shipped by someone else, who is
not in my organisation.
[2] The thread in which my piece of code runs, is created by someone
else, so I cant increase the stack size of the thread.
So, whats the solution ?
Thanks
Aditya Kulkarni
Hi,

You can try to set the default stack size of each thread of your process
using (if i remember) pthread_set_attr.
This call must be done before creating any thread.

Rémy
Mike Stroyan
2004-02-02 18:59:02 UTC
Permalink
In comp.sys.hp.apps "Rémy" <***@cgeyt.com> wrote:

|You can try to set the default stack size of each thread of your process
|using (if i remember) pthread_set_attr.
|This call must be done before creating any thread.

The standard call, pthread_attr_setstacksize(), will only work if
you have a chance to get at an attr parameter passed into pthread_create().

There is a non-portable HP-UX function, pthread_default_stacksize_np(),
which will change the default stack size for threads that are created
without an explicit stack size.
--
Mike Stroyan, ***@hp.com
Aditya Kulkarni
2004-02-03 10:56:51 UTC
Permalink
Post by Mike Stroyan
|You can try to set the default stack size of each thread of your process
|using (if i remember) pthread_set_attr.
|This call must be done before creating any thread.
The standard call, pthread_attr_setstacksize(), will only work if
you have a chance to get at an attr parameter passed into pthread_create().
There is a non-portable HP-UX function, pthread_default_stacksize_np(),
which will change the default stack size for threads that are created
without an explicit stack size.
[1] I dont have a chance to set the attrributes for the thread. So
pthread_attr_setstacksize is out of question.

[2] pthread_default_stacksize_np only changes the default value of
stacksize, and this gets reflected in threads which havent been
created as yet. It does not alter the stack allocated to already
created threads.

[3] also, my code needs to be portable across different versions of
HP. As you say, the XXX_np function is not portable, so its not worth
taking the risk.

I mite as well do this : In the thread in which ( call it T1 ) I am, I
can create another thread T2. T2 will have more stack size, and I will
call the library function F() inside T2. T1 waits for T2 to complete.
Does this sound palatable ?

Aditya Kulkarni
Mike Stroyan
2004-02-03 19:19:38 UTC
Permalink
In comp.sys.hp.hpux Aditya Kulkarni <***@yahoo.com> wrote:

|I mite as well do this : In the thread in which ( call it T1 ) I am, I
|can create another thread T2. T2 will have more stack size, and I will
|call the library function F() inside T2. T1 waits for T2 to complete.
|Does this sound palatable ?

That should be fine. The only trouble I could see from that would
be some very unlikely dependence on the exact thread ID in the library
function. It certainly does not sound like that library function would
be doing anything exotic like accessing thread specific data set up in
the first thread.
--
Mike Stroyan, ***@hp.com
Rick Jones
2004-02-03 23:12:47 UTC
Permalink
On the surface, it sounds like the various parties need to get
together and architect the complete soultion.

However, if the realities dictate doing things ad hoc, would perhaps
some judicious use of LD_PRELOAD help to get the default stack size
altered with the aforementioned pthread_default_stacksize_np() call?

rick jones
--
firebug n, the idiot who tosses a lit cigarette out his car window
these opinions are mine, all mine; HP might not want them anyway... :)
feel free to post, OR email to raj in cup.hp.com but NOT BOTH...
Loading...