bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Use malloca instead alloca


From: KOSAKI Motohiro
Subject: Re: [PATCH] Use malloca instead alloca
Date: Sun, 30 Dec 2012 12:48:50 -0500

>> For platform specific way best solution is to read where bottom of stack is
>> and allocate only when at least say 32768 bytes are left.
>> >
> And when knowing stack boundaries I could also recognize stack pointer
> by single comparison.
>
> It needs to define _STACK_TOP,_STACK_CUP, _STACK_SIZE macros for stack 
> parameters.
> I can find them by pthread_attr_getstack but this call is slow.

I think this approach has two issues.

1) On LInux, RLIMIT_STACK doesn't affect to main thread. so there is
no reliable stack limit detection way. Think mmap vs stack expansion
race case for example.
2) setcontext/getcontext family provide to implement userland thread
(it is sometimes called fiber or green thread). so
pthread_attr_getstack is not suitable for getting generic  stack
knowledge.

I suppose original hardcoded 4096 boundary is best.

Thank you.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]