From owner-freebsd-bugs@FreeBSD.ORG Fri Sep 15 10:20:30 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org 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 7C86016A407 for ; Fri, 15 Sep 2006 10:20:30 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E416E43D79 for ; Fri, 15 Sep 2006 10:20:28 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k8FAKSvW044492 for ; Fri, 15 Sep 2006 10:20:28 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k8FAKSS2044491; Fri, 15 Sep 2006 10:20:28 GMT (envelope-from gnats) Date: Fri, 15 Sep 2006 10:20:28 GMT Message-Id: <200609151020.k8FAKSS2044491@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Ruslan Ermilov Cc: Subject: Re: bin/100443 : awk(1) dies with SIGBUS when processing INDEX-6 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Ruslan Ermilov List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Sep 2006 10:20:30 -0000 The following reply was made to PR bin/100443; it has been noted by GNATS. From: Ruslan Ermilov To: "Devon H. O'Dell" , Dmitry Marakasov Cc: bug-followup@FreeBSD.org Subject: Re: bin/100443 : awk(1) dies with SIGBUS when processing INDEX-6 Date: Fri, 15 Sep 2006 14:14:17 +0400 On Thu, Sep 14, 2006 at 07:15:00PM -0400, Devon H. O'Dell wrote: > Ruslan Ermilov wrote: > >On Thu, Sep 14, 2006 at 09:40:24PM +0000, Devon H. O'Dell wrote: > [snip] > >> Do we need to send this upstream? > >> > >Yes, of course. > > I sent an email to BWK a couple hours ago -- hopefully he'll get it soon :) > There's another function, refldbld(), that needs a similar fix. Actually, your patch makes it so that if "n == fieldssize" then malloc() will be redundantly called, when we enter this function again and again. I think the following should fix it better: %%% Index: lib.c =================================================================== RCS file: /home/ncvs/src/contrib/one-true-awk/lib.c,v retrieving revision 1.1.1.4 diff -u -p -r1.1.1.4 lib.c --- lib.c 16 May 2005 19:11:33 -0000 1.1.1.4 +++ lib.c 15 Sep 2006 10:10:59 -0000 @@ -58,7 +58,7 @@ static Cell dollar1 = { OCELL, CFLD, NUL void recinit(unsigned int n) { if ( (record = (char *) malloc(n)) == NULL - || (fields = (char *) malloc(n)) == NULL + || (fields = (char *) malloc(n+1)) == NULL || (fldtab = (Cell **) malloc((nfields+1) * sizeof(Cell *))) == NULL || (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL ) FATAL("out of space for $0 and fields"); %%% Could you please send me the code/scripts to reproduce a segfault? Cheers, -- Ruslan Ermilov ru@FreeBSD.org FreeBSD committer