From owner-freebsd-bugs Mon Jul 8 17:50:14 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C962237B401 for ; Mon, 8 Jul 2002 17:50:02 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 31AD143E31 for ; Mon, 8 Jul 2002 17:50:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g690o2JU040952 for ; Mon, 8 Jul 2002 17:50:02 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g690o2wA040951; Mon, 8 Jul 2002 17:50:02 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 57D5137B400 for ; Mon, 8 Jul 2002 17:45:48 -0700 (PDT) Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1AFA143E52 for ; Mon, 8 Jul 2002 17:45:48 -0700 (PDT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g690jlOT030264 for ; Mon, 8 Jul 2002 17:45:47 -0700 (PDT) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.4/8.12.4/Submit) id g690jlNR030263; Mon, 8 Jul 2002 17:45:47 -0700 (PDT) Message-Id: <200207090045.g690jlNR030263@www.freebsd.org> Date: Mon, 8 Jul 2002 17:45:47 -0700 (PDT) From: David Dunham To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: misc/40363: Syslogd crashes in function markit 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 >Number: 40363 >Category: misc >Synopsis: Syslogd crashes in function markit >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jul 08 17:50:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: David Dunham >Release: FreeBSD 5.0 >Organization: Isilon Systems >Environment: FreeBSD dwd_1 5.0-20010301-CURRENT i386 >Description: Syslogd crashes when it tries to access memory it has just freed. In the function markit q is freed and then TAILQ_NEXT is called using q. >How-To-Repeat: This is extremely rare the only way I was able to get it to happen consistently was to change syslogd as follows: --- syslogd.c.orig Mon Jul 8 17:26:21 2002 +++ syslogd.c Mon Jul 8 17:24:16 2002 @@ -1084,9 +1084,9 @@ break; } } - if (writev(f->f_file, iov, 7) < 0) { + if (writev(f->f_file, iov, 7) < 0 || 1) { int e = errno; - (void)close(f->f_file); + /* (void)close(f->f_file);*/ if (f->f_un.f_pipe.f_pid > 0) deadq_enter(f->f_un.f_pipe.f_pid, f->f_un.f_pipe.f_pname); You also should probably run electric fence or some other memory debugger. >Fix: Get the next on the queue from the iterator before freeing it. --- syslogd.c.orig Mon Jul 8 17:26:21 2002 +++ syslogd.c Mon Jul 8 17:24:16 2002 @@ -1775,7 +1775,7 @@ markit(void) { struct filed *f; - dq_t q; + dq_t q, next; now = time((time_t *)NULL); MarkSeq += TIMERINTVL; @@ -1796,7 +1796,9 @@ } /* Walk the dead queue, and see if we should signal somebody. */ - TAILQ_FOREACH(q, &deadq_head, dq_entries) { + for (q = TAILQ_FIRST(&deadq_head); q != NULL; q = next) { + next = TAILQ_NEXT(q, dq_entries); + switch (q->dq_timeout) { case 0: /* Already signalled once, try harder now. */ >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message