Operating System - HP-UX
1832285 Members
2654 Online
110041 Solutions
New Discussion

Re: Pid <nnn> killed due to trashed stack.

 
SOLVED
Go to solution
devshlom
Regular Advisor

Pid <nnn> killed due to trashed stack.

Hi,
I'm havign an executable that works fine in all the other UNIX env (solaris,linux, aix) - but in HP-UX I get this error:
"Pid killed due to trashed stack.
Pid was killed due to failure in writing the signal context. Illegal instruction (core dumped)"
The exe was compiled and linked as 32bit app.
=========
sys info:
=========
HP-UX hpux B.11.23 U 9000/800 3697136004 unlimited-user license

I've installed PHKL_36745 patch with all its dependencies, but it didn't help.

Anyone has some ideas?
17 REPLIES 17
James R. Ferguson
Acclaimed Contributor

Re: Pid <nnn> killed due to trashed stack.

Hi:

This is really a continuation of your earlier thread:

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1226923

As I said before:

It is possible that you experienced a stack overflow due to excessive recursive calls or due to a buffer overrun.

Perhaps a 'tusc' trace would help you.

Please also give consideration to the guidelines here:

http://forums11.itrc.hp.com/service/forums/helptips.do?#28

Regards!

...JRF...
devshlom
Regular Advisor

Re: Pid <nnn> killed due to trashed stack.

Hi James,
I closed the mentioned thread.
Regarding your answer:
can you give me some more details about this 'tusc'? I don't have such utility on my system.
Is it something like 'pstack' and if not - do you know if there is any took that is similar to pstack on hp-ux?
James R. Ferguson
Acclaimed Contributor

Re: Pid <nnn> killed due to trashed stack.

Hi (again):

You can still open your closed thread and assign points for the help you received there.

You can obtain 'tusc' from the HP-UX Porting Center:

http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/tusc-7.9/

As for the Solaris 'pstack', the HP-UX counterpart would be 'gdb' or the HP form 'wdb':

http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=29080f1bace021100f1bace02110275d6e10RCRD

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: Pid <nnn> killed due to trashed stack.

Hi (again):

You might try increasing your 'maxssiz' under the assumption that you are doing recursive procedure calls (are you?) or have a program that allocates a large amount of data on the stack.

Examine your current settings with 'kctune' and confine your change to the 32-bit 'maxssiz' since this is for a 32-bit application. See the manpages for more information:

http://docs.hp.com/en/B3921-60631/maxssiz.5.html

Regards!

...JRF...
devshlom
Regular Advisor

Re: Pid <nnn> killed due to trashed stack.

I've already modified all the relevant maxssize, maxtsize and maxdsize to the maximum legal value...
and it didn't help - as you can guess.
notes:
1. My application is multithreaded
2. If this code didn't work fine on the other UNIX env I would continue digging my code searching for some bug.

tx.
Dennis Handly
Acclaimed Contributor

Re: Pid <nnn> killed due to trashed stack.

>I've already modified all the relevant maxssiz, maxtsiz and maxdsiz to the maximum legal value.

You should immediately reduce maxssiz back to a reasonable value, 80 Mb. Making it bigger will reduce from maxdsiz, if set to 1 Gb or larger.

>1. My application is multithreaded

Then maxssiz won't help. You need to increase the thread stacksize with pthread_attr_setstacksize(3) or pthread_default_stacksize_np(3T).
Or export PTHREAD_DEFAULT_STACK_SIZE if you have a recent libpthread patch.
devshlom
Regular Advisor

Re: Pid <nnn> killed due to trashed stack.

tx man,
can you specify how to do it?
Dennis Handly
Acclaimed Contributor

Re: Pid <nnn> killed due to trashed stack.

>can you specify how to do it?

Which? They have man pages.

You need to increase the thread stacksize with 1) pthread_attr_setstacksize(3)
2) pthread_default_stacksize_np(3T).
3) Or export PTHREAD_DEFAULT_STACK_SIZE if you have a recent libpthread patch.

Are you using pthread_attr_setstacksize now?
If you are, make it bigger, else use 2) or 3).
devshlom
Regular Advisor

Re: Pid <nnn> killed due to trashed stack.

hi again,
I want to use the 3 - what value you suggest me to set for this env var?
devshlom
Regular Advisor

Re: Pid <nnn> killed due to trashed stack.

Hi denis,
the 3rd option solved the probelm!!!!
I just need to know know if there is anyway to chnage the PTHREAD_DEFAULT_STACK_SIZE permanently via the sam utility?
1. I need to find a nice way to recomment our customers.
2. Do you know what should be the minimal value for this env var so that my application work fine?

thank alot!!!!!!
shlom
Dennis Handly
Acclaimed Contributor

Re: Pid <nnn> killed due to trashed stack.

>I just need to know know if there is anyway to change the PTHREAD_DEFAULT_STACK_SIZE permanently via the sam utility?

No, you need to export it. Possibly in your .profile or /etc/profile.

>1. I need to find a nice way to recommend our customers.

You can change your application to do 1).

>2. Do you know what should be the minimal value for this env var so that my application work fine?

No, you have to know your application. (How many threads?) The default for PA is 64 Kb For IPF it is 256 Kb but that needs to be divided by 2.

What value did you use to get it to work?
devshlom
Regular Advisor

Re: Pid <nnn> killed due to trashed stack.

Hi man,
well done for your answer, again.
1. my application uses at least 9 threads, but it can be configured to work with a lot more... more than INT_MAX (2147483647) - so, any recommended value?

2. what is the standard way for working on HP-UX? if I have a script that start my app - do you think I better export PTHREAD_DEFAULT_STACK_SIZE in it (before start the app) or do some changes in my application (is it ok to do it on the main?) for HP-UX?

tx again.
devshlom
Regular Advisor

Re: Pid <nnn> killed due to trashed stack.

Hi,

I probabaly did something wrong.
currently I can make it work again:
sometimes for PTHREAD_DEFAULT_STACK_SIZE, such as 4096 the app crashes when it tries to start with BUS ERROR and sometimes it gives me the original problem...
what's going on?! after I saw the light?!!
devshlom
Regular Advisor

Re: Pid <nnn> killed due to trashed stack.

yes - I found my mistke.
pls ignore my last msg.
When I set PTHREAD_DEFAULT_STACK_SIZE to max 10240000 for example it worked fine.

I read in the man that the max allowed for this one is 10MB, but what is the size unit it gets?
Dennis Handly
Acclaimed Contributor
Solution

Re: Pid <nnn> killed due to trashed stack.

>1. but it can be configured to work with a lot more - so, any recommended value?

If they are using the all of a CPU, having more than the number of CPUs is not helpful.

>2. what is the standard way for working on HP-UX? if I have a script that start my app - do you think I better export PTHREAD_DEFAULT_STACK_SIZE in it or do some changes in my application (is it ok to do it on the main?) for HP-UX?

The right way is to call pthread_attr_setstacksize.
But you could either export PTHREAD_DEFAULT_STACK_SIZE or call pthread_default_stacksize_np in your main.

>sometimes for PTHREAD_DEFAULT_STACK_SIZE, such as 4096
>but what is the size unit it

This is in bytes:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1110034

>When I set PTHREAD_DEFAULT_STACK_SIZE to max 10240000 for example it worked fine.

Why would you want it that high? Try with 256 KB, 262144.
devshlom
Regular Advisor

Re: Pid <nnn> killed due to trashed stack.

hi Dennis,

tx a lot for your helpul answers!
I will try to use also the function in my main and see how it goes.
I leave this thread open till I done and let everyone knows the results.
devshlom
Regular Advisor

Re: Pid <nnn> killed due to trashed stack.

Thanks all.
I have 2 options to solve this problem:
1. use the env variable with 128K
2. use the pthread_default_stacksize_np in the code, before any thread begin (except for the main of course)

shlom