NetBSD Problem Report #39501

From dholland@eecs.harvard.edu  Mon Sep  8 03:00:23 2008
Return-Path: <dholland@eecs.harvard.edu>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id C3B1663B853
	for <gnats-bugs@gnats.NetBSD.org>; Mon,  8 Sep 2008 03:00:22 +0000 (UTC)
Message-Id: <20080908025728.33BE9F995@tanaqui.eecs.harvard.edu>
Date: Sun,  7 Sep 2008 22:57:28 -0400 (EDT)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@gnats.NetBSD.org
Subject: the new invalid regexp warning sometimes causes awk to bomb
X-Send-Pr-Version: 3.95

>Number:         39501
>Category:       bin
>Synopsis:       the new invalid regexp warning sometimes causes awk to bomb
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 08 03:05:00 +0000 2008
>Closed-Date:    Wed Sep 10 00:34:31 +0000 2008
>Last-Modified:  Wed Sep 10 00:34:31 +0000 2008
>Originator:     David A. Holland
>Release:        NetBSD 4.99.72 (20080907)
>Organization:
>Environment:
System: NetBSD tanaqui 4.99.54 NetBSD 4.99.54 (TANAQUI) #21: Fri Feb 29 12:31:31 EST 2008 dholland@tanaqui:/usr/src/sys/arch/i386/compile/TANAQUI i386
Architecture: i386
Machine: i386
>Description:

Sometimes (usually in nontrivial cases in the middle of large builds),
the new warning in awk about invalid regexp strings like "\." causes a
syntax error as well as the intended warning.

>How-To-Repeat:

Here's a relatively small test case.
(Derived from pkgsrc/mk/scripts/genindex.awk; see PR 39339. It has
8-space tabs and no trailing whitespace, which may be important, as
the exact formatting matters.)

   ------

END {
	exit 0;
}

function find_all_depends(pkg, type, pkgreg, i, deps, depdir, topdep){

	alldepends[pkg] = " ";

	alldepends[pkg] = uniq(alldepends[pkg]);
	if (debug) printf("\tuniq() output alldepends[%s] = %s\n",
			  pkg, alldepends[pkg]);
	return(alldepends[pkg]);
}

function reg2str(reg){
	gsub(/\./, "\\\.", reg);
	gsub(/\+/, "\\\+", reg);
	gsub(/\*/, "\\\*", reg);
	gsub(/\?/, "\\\?", reg);
	gsub(/\[/, "\\\[", reg);
	gsub(/\]/, "\\\]", reg);
	reg = " "reg" ";
	return(reg);
}

function uniq(list, deps, i, ulist){
	ulist = " ";
}



   ------

>Fix:

The problem is that the code that prints the context of a diagnostic
message [eprint() in lib.c] attempts to read from the input buffer
[input() in lex.c] and restore it when it's done, I think, but it
doesn't always work. In fact, I don't particularly understand what
it's trying to do at all, so I'm not sure how to fix it.

It might be an adequate workaround to avoid calling eprint() from
WARNING(), but it'd be better to fix it properly...

>Release-Note:

>Audit-Trail:
From: Christos Zoulas <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/39501 CVS commit: src/dist/nawk
Date: Tue,  9 Sep 2008 21:47:34 +0000 (UTC)

 Module Name:	src
 Committed By:	christos
 Date:		Tue Sep  9 21:47:34 UTC 2008

 Modified Files:
 	src/dist/nawk: lib.c

 Log Message:
 PR/39501: David Holland: Don't print the remainder of the line in the error
 context because it can confuse input parsing in warnings. A full explanation
 is in the code.


 To generate a diff of this commit:
 cvs rdiff -r1.12 -r1.13 src/dist/nawk/lib.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Wed, 10 Sep 2008 00:34:31 +0000
State-Changed-Why:
Fixed, thanks.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.