From owner-freebsd-bugs Wed Oct 24 5:40:10 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id C5BC637B407 for ; Wed, 24 Oct 2001 05:40:02 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f9OCe2T97018; Wed, 24 Oct 2001 05:40:02 -0700 (PDT) (envelope-from gnats) Date: Wed, 24 Oct 2001 05:40:02 -0700 (PDT) Message-Id: <200110241240.f9OCe2T97018@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: "Carlos F. A. Paniago" Subject: Re: misc/30631: readdir_r() SEGV on large directories Reply-To: "Carlos F. A. Paniago" Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR misc/30631; it has been noted by GNATS. From: "Carlos F. A. Paniago" To: freebsd-gnats-submit@FreeBSD.org, jfbauer@nfr.com Cc: Subject: Re: misc/30631: readdir_r() SEGV on large directories Date: Wed, 24 Oct 2001 10:38:20 -0200 I traced the problem . The problem occurs only with -pthread library (not the normal libc). The problem is to memcpy the structure memcpy(entry, dp, sizeof *entry); in the pthread library sometimes dp doen't have the correct size (I don't know why or where this is happening). I know that if we change this to memcpy(entry, dp, _GENERIC_DIRSIZ(dp)); it begins to work (and we cut a lot of unnecessary copy in this ugly struct that is dirent). The patch to solve this is here (someone have to test and apply): in the /usr/src directory: ------------ diff -c lib/libc/gen/readdir.c.old lib/libc/gen/readdir.c *** lib/libc/gen/readdir.c.old Wed Oct 24 10:21:17 2001 --- lib/libc/gen/readdir.c Wed Oct 24 10:23:35 2001 *************** *** 111,117 **** errno = saved_errno; if (dp != NULL) ! memcpy(entry, dp, sizeof *entry); #ifdef _THREAD_SAFE _FD_UNLOCK(dirp->dd_fd, FD_READ); --- 111,117 ---- errno = saved_errno; if (dp != NULL) ! memcpy(entry, dp, _GENERIC_DIRSIZ(dp)); #ifdef _THREAD_SAFE _FD_UNLOCK(dirp->dd_fd, FD_READ); ------------- Thanks for fixing this: Paniago To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message