This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: linuxthreads patch


"Matthias Urlichs" <smurf@noris.de> writes:
> Without this patch, threaded Perl's tests will block on exit because the
> thread manager manages to segfault (or whatever).
> 
There's another bug in linuxthreads/manager.c, at the end of pthread_free:
...
  if (!th->p_userstack)
    {
      /* Free the stack and thread descriptor area */
      munmap((caddr_t) ((char *)(th+1) - STACK_SIZE), STACK_SIZE);
      if (th->p_guardsize != 0)
        munmap(th->p_guardaddr, th->p_guardsize);
    }

Unfortunately, (th+1)-STACK_SIZE includes th, which gets unmapped, which
kills the manager as soon as it tries to access th->p_guardsize.
This works:
      [...]
      if (th->p_guardsize != 0)
        munmap(th->p_guardaddr, th->p_guardsize);
      munmap((caddr_t) ((char *)(th+1) - STACK_SIZE), STACK_SIZE);

The reason the above code doesn't usually crash is because _usually_
there's a stack above the unmapped area, which gets auto-extended
downwards. But not always.

With this patch applied, mysql and nscd are _finally_ stable under glibc
2.1.current. Phew. We lost half a day of WWW service, including for a
rather big customer who's now slightly upset with us, due to that bug.  :-(
The main problem was that when nscd hangs, _nothing_ works; if you can't
NFS-write to /var/run or already have a root shell logged in, it's Big Red
Button time. :-(  A timeout for the nscd client in glibc would be helpful. 

NB, nscd should check the validity of its cache, sometime before an entry
expires, if it has been used during the last umpteen seconds ... any takers? 

-- 
Matthias Urlichs
noris network GmbH


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]