[PATCH] __libc_alloca_cutoff (aka make mysql and others apps with very low RLIMIT_STACK setting happy)
Roland McGrath
roland@redhat.com
Mon Oct 7 21:43:00 GMT 2002
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Jakub Jelinek wrote:
>
> > --- libc/include/alloca.h.jj 2002-09-30 16:45:04.000000000 +0200
> > +++ libc/include/alloca.h 2002-10-08 00:12:01.000000000 +0200
> > @@ -11,4 +11,16 @@ extern void *__alloca (size_t __size);
> > # define __alloca(size) __builtin_alloca (size)
> > #endif /* GCC. */
> >
> > +extern size_t __libc_alloca_cutoff;
> > +libc_hidden_proto (__libc_alloca_cutoff)
>
> We should have this variable per-thread (use __thread). Tis way a few
> worker threads using very small stack do not affect to whole process.
Conversely instead of a variable we could have a function that's given the
size and returns whether to use alloca or malloc. The libc version can
just say to always use alloca, I don't care about supporting tiny
RLIMIT_STACK values for single-threaded programs. The libpthread version
can look at the thread's stack size vs the allocation, and perhaps even
look at the current stack depth. Then we don't have to diddle setrlimit
and all the rest, or add the word of TLS data
More information about the Libc-hacker
mailing list