NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/47271: host (1) dumps core on latest netbsd-6



The following reply was made to PR bin/47271; it has been noted by GNATS.

From: Taylor R Campbell <campbell+netbsd%mumble.net@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: netbsd-bugs%NetBSD.org@localhost
Subject: Re: bin/47271: host (1) dumps core on latest netbsd-6
Date: Sun, 2 Dec 2012 18:56:03 +0000

 This is a multi-part message in MIME format.
 --=_vXlEPmH0ra2WG62OZf6ZyohNndGD9pGb
 
 The attached patch works around the problem, at least on amd64, but I
 think we ought to discuss whether it is actually appropriate to double
 the size of each pthread for the thread-specific data deletion kludge,
 both in HEAD and in netbsd-6.  For now, until that discussion happens,
 riz has reverted the TSD change in netbsd-6.
 
 --=_vXlEPmH0ra2WG62OZf6ZyohNndGD9pGb
 Content-Type: text/plain; charset="ISO-8859-1"; name="nb6-pthread-fix"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="nb6-pthread-fix.patch"
 
 Index: lib/libpthread/pthread.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /cvsroot/src/lib/libpthread/pthread.c,v
 retrieving revision 1.125.4.1
 diff -p -u -r1.125.4.1 pthread.c
 --- lib/libpthread/pthread.c   7 May 2012 03:12:33 -0000       1.125.4.1
 +++ lib/libpthread/pthread.c   2 Dec 2012 18:50:03 -0000
 @@ -1274,22 +1274,32 @@ pthread__stackid_setup(void *base, size_
  {
        pthread_t t;
        void *redaddr;
 -      size_t pagesize;
 +      size_t pagesize, bytes_needed;
        int ret;
 =20
        t =3D base;
        pagesize =3D (size_t)sysconf(_SC_PAGESIZE);
 +      bytes_needed =3D roundup(sizeof(*t), pagesize);
 +
 +      if (pagesize >=3D size)
 +              return ENOMEM;
 +      if (bytes_needed >=3D (size - pagesize))
 +              return ENOMEM;
 =20
        /*
         * Put a pointer to the pthread in the bottom (but
           * redzone-protected section) of the stack.=20
 +       *
 +       * XXX If the stack grows up, the pthread is *not*
 +       * protected by the redzone.
         */
 -      redaddr =3D STACK_SHRINK(STACK_MAX(base, size), pagesize);
 -      t->pt_stack.ss_size =3D size - 2 * pagesize;
 +      t->pt_stack.ss_size =3D size - bytes_needed - pagesize;
  #ifdef __MACHINE_STACK_GROWS_UP
 -      t->pt_stack.ss_sp =3D (char *)(void *)base + pagesize;
 +      redaddr =3D STACK_SHRINK(STACK_MAX(base, size), pagesize);
 +      t->pt_stack.ss_sp =3D (char *)(void *)base + bytes_needed;
  #else
 -      t->pt_stack.ss_sp =3D (char *)(void *)base + 2 * pagesize;
 +      redaddr =3D STACK_SHRINK(STACK_MAX(base, size), bytes_needed);
 +      t->pt_stack.ss_sp =3D (char *)(void *)base + bytes_needed + pagesize;
  #endif
        /* Protect the next-to-bottom stack page as a red zone. */
        ret =3D mprotect(redaddr, pagesize, PROT_NONE);
 
 --=_vXlEPmH0ra2WG62OZf6ZyohNndGD9pGb--
 


Home | Main Index | Thread Index | Old Index