[mistry.7@osu.edu: Re: FreeBSD and wine mmap]

Daniel Eischen deischen at gdeb.com
Wed Sep 8 12:09:47 PDT 2004


On Wed, 8 Sep 2004, Brian Fundakowski Feldman wrote:

> I don't think that any allocated "red zones" should be left empty --
> they should be explicitly allocated with no protection so that actually
> free memory space can be explicitly searched for.  Comments?

Yes, that's fine.  See specific comments below.

> > Index: lib/libpthread/thread/thr_stack.c
> > ===================================================================
> > RCS file: /usr/ncvs/src/lib/libpthread/thread/thr_stack.c,v
> > retrieving revision 1.8
> > diff -u -r1.8 thr_stack.c
> > --- lib/libpthread/thread/thr_stack.c 14 Sep 2003 22:39:44 -0000 1.8
> > +++ lib/libpthread/thread/thr_stack.c 29 Aug 2004 04:50:28 -0000
> > @@ -214,6 +214,17 @@
> >         stacksize, PROT_READ | PROT_WRITE, MAP_STACK,
> >         -1, 0)) == MAP_FAILED)
> >     attr->stackaddr_attr = NULL;
> > +  if (attr->stackaddr_attr != NULL) {
> > +   void *red;

Declare red above with rest of locals.

> > +
> > +   red = mmap((char *)attr->stackaddr_attr + stacksize,
> > +       _thr_guard_default, PROT_NONE,
> > +       MAP_ANON | MAP_FIXED | MAP_PRIVATE, -1, 0);
> > +   if (red == MAP_FAILED) {
> > +    (void)munmap(attr->stackaddr_attr, stacksize);
> > +    attr->stackaddr_attr = NULL;
> > +   }
> > +  }
> >   }
> >   if (attr->stackaddr_attr != NULL)
> >    return (0);

I don't know if this was stripped of tabs, but please use them
and obey style(9).

-- 
Dan Eischen



More information about the freebsd-threads mailing list