Opened 16 years ago

Closed 16 years ago

#2559 closed enhancement (fixed)

[pthreads] Define PTHREAD_STACK_MIN

Reported by: andreasf Owned by: axeld
Priority: low Milestone: R1
Component: - General Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Platform: x86

Description

I encountered the following code snippet in Mono:

ret = pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);

FreeBSD and NetBSD were special-cased to use 65536 instead.

No idea how standard this is, but maybe we should define it to something sensible?

Change History (4)

comment:1 by bonefish, 16 years ago

Priority: normallow

PTHREAD_STACK_MIN is not part of the POSIX standard (at least it's not supposed to be defined in <pthread.h> or <unistd.h>), and I wouldn't even know what kind of value it is supposed to have. The minimal stack is one page (4 KB), which is probably even sufficient for all libroot functions (that is ATM I can't think of any that would use more).

comment:2 by andreasf, 16 years ago

FYI in this particular case, using 4096 in place of PTHREAD_STACK_MIN badly freezes the system. Same for 8192 (seen on OSX in limits.h). Using 65536 doesn't.

vm_page_fault: vm_soft_fault returned error 'Bad address' on fault at 0x70002007
create_thread: unable to create proper user stack!                              
CPU 0 halted!

in reply to:  1 comment:3 by korli, 16 years ago

Replying to bonefish:

PTHREAD_STACK_MIN is not part of the POSIX standard (at least it's not supposed to be defined in <pthread.h> or <unistd.h>), and I wouldn't even know what kind of value it is supposed to

PTHREAD_STACK_MIN should be defined in limits.h.

Our pthread_attr_setstacksize() checks against MIN_USER_STACK_SIZE whereas it should be PTHREAD_STACK_MIN.

comment:4 by axeld, 16 years ago

Resolution: fixed
Status: newclosed

Fixed in hrev26982. If the value of PTHREAD_STACK_MIN is problematic, please yell :-)

Note: See TracTickets for help on using tickets.