This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Problem with stack size in pthreads
On Sat, Jul 14, 2001 at 08:49:40AM -0700, H . J . Lu wrote:
> On Fri, Jul 13, 2001 at 11:49:33PM -0700, H . J . Lu wrote:
> > On Thu, Jul 12, 2001 at 12:55:56PM -0700, Hui Huang wrote:
> > > Ulrich Drepper wrote:
> > >
> > > > Andreas Jaeger <aj@suse.de> writes:
> > > >
> > > >
> > > >>>This is not supposed to happen because we made a setrlimit() call.
> > > >>>Testcase?
> > > >>>
> > > >>JDK :-(
> > > >>
> > > >
> > > > Right! Nice joke.
> > > >
> > > >
> > >
> > > Why do you think it's a joke? It's a bug.
> > >
> > > Call getrlimit(RLIMIT_STACK, &rlim) in any C program and run it with
> > > "LD_ASSUME_KERNEL=2.2.5", you'll see stack limit is not correctly set.
> > > I assume you want to set stack limit to STACK_SIZE-pagesize = 2040K,
> > > but no, it's not set to that value.
> > >
> >
> > That is because __pthread_init_max_stacksize is not called in your
> > testcase. Should we always call __pthread_init_max_stacksize for
> > pthreads, something like the patch encloded here?
> >
> >
>
> Any comments on this patch?
>
>
> H.J.
> ----
> 2001-07-14 H.J. Lu <hjl@gnu.org>
>
> * attr.c (__pthread_attr_setstacksize): Don't call
> __pthread_init_max_stacksize.
>
> * pthread.c (__pthread_init_max_stacksize): Renamed to ...
> (pthread_init_max_stacksize): This. Make it static.
> (pthread_initialize): Call pthread_init_max_stacksize here.
> (__pthread_initialize_manager): Don't call
> __pthread_init_max_stacksize.
>
Well, it will always limit the stack for the initial thread. Here
is a new patch.
H.J.
---
2001-07-14 H.J. Lu <hjl@gnu.org>
* internals.h (__pthread_max_stacksize): Always declare.
* specific.c (__pthread_key_create): Initialzie
__pthread_max_stacksize.
--- linuxthreads/internals.h.stack Mon Jun 18 14:19:52 2001
+++ linuxthreads/internals.h Sat Jul 14 11:52:57 2001
@@ -281,10 +281,8 @@ extern int __pthread_manager_reader;
extern char *__pthread_manager_thread_bos;
extern char *__pthread_manager_thread_tos;
-#ifdef FLOATING_STACKS
/* Maximum stack size. */
extern size_t __pthread_max_stacksize;
-#endif
/* Pending request for a process-wide exit */
--- linuxthreads/specific.c.stack Wed Dec 27 09:16:24 2000
+++ linuxthreads/specific.c Sat Jul 14 11:48:26 2001
@@ -42,6 +42,11 @@ int __pthread_key_create(pthread_key_t *
{
int i;
+ /* We have to make sure the initial thread's stack doesn't grow
+ too large. */
+ if (__pthread_max_stacksize == 0)
+ __pthread_init_max_stacksize ();
+
pthread_mutex_lock(&pthread_keys_mutex);
for (i = 0; i < PTHREAD_KEYS_MAX; i++) {
if (! pthread_keys[i].in_use) {