This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: [PATCH] attr.c in _STACK_GROWS_UP case.
- From: Jakub Jelinek <jakub at redhat dot com>
- To: "Carlos O'Donell" <carlos at baldric dot uwo dot ca>
- Cc: libc-alpha <libc-alpha at sources dot redhat dot com>
- Date: Sun, 28 Dec 2003 22:26:52 +0100
- Subject: Re: [PATCH] attr.c in _STACK_GROWS_UP case.
- References: <20031228231554.GB27911@systemhalted>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Sun, Dec 28, 2003 at 06:15:54PM -0500, Carlos O'Donell wrote:
>
> libc-alpha,
>
> I posted a patch for this a while ago, though now I've trimmed it down
> to a minimal change that works. Works on i386 and hppa.
>
> This reverses the logic in linuxthreads for _STACK_GROWS_UP when scanning
> the /proc/self/maps entries looking for the stack. In the _S_G_U case we
> consume memory from "from" upward, in the _S_G_D case we move from "to"
> downward.
You should at least make sure it doesn't wrap in the address space.
E.g.
attr->__stackaddr = (void *) from;
if ((size_t) addr->__stacksize > ~(size_t) attr->__stackaddr)
attr->__stacksize = ~(size_t) attr->__stackaddr;
> 2003-12-28 Carlos O'Donell <carlos@baldric.uwo.ca>
>
> * attr.c (pthread_getattr_np): Add _STACK_GROWS_UP case.
>
> Index: linuxthreads/attr.c
> ===================================================================
> RCS file: /cvs/glibc/libc/linuxthreads/attr.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 attr.c
> --- linuxthreads/attr.c 23 Sep 2003 06:12:59 -0000 1.33
> +++ linuxthreads/attr.c 28 Dec 2003 23:14:15 -0000
> @@ -455,12 +455,17 @@ int pthread_getattr_np (pthread_t thread
> {
> /* Found the entry. Now we have the info we need. */
> attr->__stacksize = rl.rlim_cur;
> +#ifndef _STACK_GROWS_UP
> attr->__stackaddr = (void *) to;
>
> /* The limit might be too high. This is a bogus
> situation but try to avoid making it worse. */
> if ((size_t) attr->__stacksize > (size_t) attr->__stackaddr)
> attr->__stacksize = (size_t) attr->__stackaddr;
> +#else
> + /* Don't check to enforce a limit on the __stacksize */
> + attr->__stackaddr = (void *) from;
> +#endif
>
> /* We succeed and no need to look further. */
> ret = 0;
Jakub