This is the mail archive of the libc-alpha@sources.redhat.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]
Other format: [Raw text]

Re: [PATCH] attr.c in _STACK_GROWS_UP case.


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


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