Ticket #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: | Has a Patch: | no | |
| Platform: | x86 | Blocking: |
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
comment:2 Changed 2 years ago by andreasf
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!
comment:3 in reply to: ↑ 1 Changed 2 years ago by korli
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.

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).