Operating System - Linux
1830026 Members
16030 Online
109998 Solutions
New Discussion

Re: 4k-"hole" in pthread stack on 11.23 Itanium

 
SOLVED
Go to solution
Michael Klein
New Member

4k-"hole" in pthread stack on 11.23 Itanium

Hi,

we're getting segfaults in one of our applications (multithreaded) while accessing an array element somewhere in the middle of the array. Elements at the beginning and at the end are fine. The array in question occupies ~64kb on the stack.

Using pstat_getprocvm() and mprotect() I found out that there is a one-page "hole" in the middle of the pthread's stack, which is neither readable nor writeable.

The attached program is a reduced test case which spawns a thread allocating an 192kb character array on the stack. That should be fine since the default stack size is 256kb.

When compiled with "aCC +DD64 -mt -g -o stackhole stackhole.c" or "gcc -g -mlp64 -pthread -o stackhole stackhole.c" it crashes at char 61456 with the default stack size.

Setting PTHREAD_DEFAULT_STACK_SIZE moves the "crash point", e.g. PTHREAD_DEFAULT_STACK_SIZE=320000 crashes at 28688.

This make only half of a thread's stack usable and clearly looks like a bug to me. Is there a patch available?

Regards

/Michael
2 REPLIES 2
Dennis Handly
Acclaimed Contributor
Solution

Re: 4k-"hole" in pthread stack on 11.23 Integrity

>This makes only half of a thread's stack usable and clearly looks like a bug to me.

You are confused. The default stacksize on IPF is 256 Kb. With half assigned to the user stack and then a guard page then the other half assigned to the RSE stack.

If you don't like the default allocation you are free to change it with:
pthread_attr_setrsestacksize_np
pthread_attr_getrsestacksize_np
pthread_default_rsestacksize_np

Michael Klein
New Member

Re: 4k-"hole" in pthread stack on 11.23 Itanium

Thanks, that explains it. I expected a guard page at the end, but seeing IPF's two distinct stacks it makes sense now.