Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Jan 2016 11:02:30 -0500
From:      Ed Maste <emaste@freebsd.org>
To:        David Chisnall <theraven@freebsd.org>
Cc:        =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= <roger.pau@citrix.com>,  FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Re: Too low PTHREAD_STACK_MIN value?
Message-ID:  <CAPyFy2BK6R90pop9v_%2BtW54cv3BoHCQkxBu4-E2fnZ1BptsfHw@mail.gmail.com>
In-Reply-To: <913B1E7A-5192-430F-ABAF-576DFCFF98E6@FreeBSD.org>
References:  <531F42CD.8020307@citrix.com> <913B1E7A-5192-430F-ABAF-576DFCFF98E6@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11 March 2014 at 20:38, David Chisnall <theraven@freebsd.org> wrote:
> On 12 Mar 2014, at 02:07, Roger Pau Monn=C3=A9 <roger.pau@citrix.com> wro=
te:
>
>> I've found out that the value PTHREAD_STACK_MIN is currently set (2048
>> bytes) seems to be way too low
>
> This looks like an error in your code.  The spec says:
>
>> PTHREAD_STACK_MIN
>> Minimum size in bytes of thread stack storage.
>> Minimum Acceptable Value: 0
>
> It is meant to be the minimum value that the system can give for a thread=
 stack.  The purpose of this constant is for languages that do their own st=
ack management bit some chain of activation records of segmented stacks, bu=
t want to use pthreads for threading, so that they can allocate the smalles=
t possible stack that allows pthread cleanup to work.
>
> Using it from C code is very likely to be a mistake.

I found that lang/polyml uses PTHREAD_STACK_MIN for a trivial signal
handler thread it creates[1]. They found it was too small and
implemented a 4K minimum bound to fix polyml on FreeBSD[2]. Even if
this isn't really the intended use of PTHREAD_STACK_MIN it suggests
the 2K x86 minimum may indeed be too low.

I ran into this while trying LLVM's libunwind, which requires more
stack space. 2K is certainly too low with LLVM libunwind. Is it
reasonable to just increase it to say 8K?

[1] https://github.com/polyml/polyml/blob/6c8add163fc39271da1056e43387a3d33=
ebd62c6/libpolyml/sighandler.cpp#L527
[2] https://github.com/polyml/polyml/commit/c59360ba74ac99bd9e3d342af214ced=
39cf0568b



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPyFy2BK6R90pop9v_%2BtW54cv3BoHCQkxBu4-E2fnZ1BptsfHw>