NetBSD Problem Report #52737

From www@NetBSD.org  Sun Nov 19 17:22:34 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 25FF57A178
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 19 Nov 2017 17:22:34 +0000 (UTC)
Message-Id: <20171119172233.6FBE07A1D6@mollari.NetBSD.org>
Date: Sun, 19 Nov 2017 17:22:33 +0000 (UTC)
From: n54@gmx.com
Reply-To: n54@gmx.com
To: gnats-bugs@NetBSD.org
Subject: bmake crash for invalid usage of .PATH
X-Send-Pr-Version: www-1.0

>Number:         52737
>Notify-List:    bsiegert@NetBSD.org
>Category:       bin
>Synopsis:       bmake crash for invalid usage of .PATH
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    sjg
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 19 17:25:00 +0000 2017
>Last-Modified:  Tue Apr 09 20:05:01 +0000 2019
>Originator:     Kamil Rytarowski
>Release:        NetBSD 8.99.6 amd64
>Organization:
TNF
>Environment:
NetBSD chieftec 8.99.6 NetBSD 8.99.6 (GENERIC) #7: Thu Nov  9 20:58:03 CET 2017  root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC amd64
>Description:
A Makefile for bmake with:

.PATH ../core

instead of

.PATH: ../core

crashes bmake:

$ make USETOOLS=no MAKEVERBOSE=3 2>&1        
make: "/public/haxm/netbsd/Makefile" line 21: Unknown directive
assertion "paths == NULL" failed: file "/usr/src/usr.bin/make/parse.c", line 1745, function "ParseDoDependency"
Abort (core dumped)
>How-To-Repeat:
$ cat Makefile                                                                                                               
.PATH ../dev
$ make
make: "/tmp/Makefile" line 1: Unknown directive
assertion "paths == NULL" failed: file "/usr/src/usr.bin/make/parse.c", line 1745, function "ParseDoDependency"
Abort (core dumped)
>Fix:
N/A

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: bin-bug-people->sjg
Responsible-Changed-By: bsiegert@NetBSD.org
Responsible-Changed-When: Mon, 08 Apr 2019 18:46:24 +0000
Responsible-Changed-Why:
Simon, could you take a look please
?


From: "Simon J. Gerraty" <sjg@juniper.net>
To: <gnats-bugs@NetBSD.org>
Cc: <gnats-admin@NetBSD.org>, <netbsd-bugs@NetBSD.org>, <bsiegert@NetBSD.org>,
        <n54@gmx.com>, <sjg@juniper.net>
Subject: Re: bin/52737 (bmake crash for invalid usage of .PATH)
Date: Mon, 8 Apr 2019 13:35:14 -0700

 > Synopsis: bmake crash for invalid usage of .PATH

 The assert could be removed, or made conditional
 on seeing valid dependency line:

 diff -r 6f103b9234c3 bmake/parse.c
 --- a/bmake/parse.c	Sun Dec 30 09:28:02 2018 -0800
 +++ b/bmake/parse.c	Mon Apr 08 13:33:09 2019 -0700
 @@ -1222,6 +1222,7 @@
      Lst 	    curTargs;	/* list of target names to be found and added
  				 * to the targets list */
      char	   *lstart = line;
 +    Boolean	    colon_seen;

      if (DEBUG(PARSE))
  	fprintf(debug_file, "ParseDoDependency(%s)\n", line);
 @@ -1229,6 +1230,7 @@

      specType = Not;
      paths = NULL;
 +    colon_seen = FALSE;

      curTargs = Lst_Init(FALSE);

 @@ -1313,6 +1315,8 @@

  	/* Insert a null terminator. */
  	savec = *cp;
 +	if (*cp == ':')
 +	    colon_seen = TRUE;
  	*cp = '\0';

  	/*
 @@ -1768,6 +1772,10 @@
      }

  out:
 +    if (paths && !colon_seen) {
 +	Lst_Destroy(paths, NULL);
 +	paths = NULL;
 +    }
      assert(paths == NULL);
      if (curTargs)
  	    Lst_Destroy(curTargs, NULL);

From: Christos Zoulas <christos@zoulas.com>
To: gnats-bugs@netbsd.org
Cc: sjg@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org,
 n54@gmx.com,
 "bsiegert@netbsd.org" <bsiegert@NetBSD.org>
Subject: Re: bin/52737 (bmake crash for invalid usage of .PATH)
Date: Tue, 9 Apr 2019 10:32:25 -0700

 I'd rather unconditionally free "paths" if it was not NULL rather than =
 add more complexity
 to the code. This function needs to be split up; it is too big and =
 complicated.

 christos

 > On Apr 8, 2019, at 4:25 PM, Simon J. Gerraty <sjg@juniper.net> wrote:
 >=20
 > The following reply was made to PR bin/52737; it has been noted by =
 GNATS.
 >=20
 > From: "Simon J. Gerraty" <sjg@juniper.net>
 > To: <gnats-bugs@NetBSD.org>
 > Cc: <gnats-admin@NetBSD.org>, <netbsd-bugs@NetBSD.org>, =
 <bsiegert@NetBSD.org>,
 >        <n54@gmx.com>, <sjg@juniper.net>
 > Subject: Re: bin/52737 (bmake crash for invalid usage of .PATH)
 > Date: Mon, 8 Apr 2019 13:35:14 -0700
 >=20
 >> Synopsis: bmake crash for invalid usage of .PATH
 >=20
 > The assert could be removed, or made conditional
 > on seeing valid dependency line:
 >=20
 > diff -r 6f103b9234c3 bmake/parse.c
 > --- a/bmake/parse.c	Sun Dec 30 09:28:02 2018 -0800
 > +++ b/bmake/parse.c	Mon Apr 08 13:33:09 2019 -0700
 > @@ -1222,6 +1222,7 @@
 >      Lst 	    curTargs;	/* list of target names to be found and =
 added
 >  				 * to the targets list */
 >      char	   *lstart =3D line;
 > +    Boolean	    colon_seen;
 >=20
 >      if (DEBUG(PARSE))
 >  	fprintf(debug_file, "ParseDoDependency(%s)\n", line);
 > @@ -1229,6 +1230,7 @@
 >=20
 >      specType =3D Not;
 >      paths =3D NULL;
 > +    colon_seen =3D FALSE;
 >=20
 >      curTargs =3D Lst_Init(FALSE);
 >=20
 > @@ -1313,6 +1315,8 @@
 >=20
 >  	/* Insert a null terminator. */
 >  	savec =3D *cp;
 > +	if (*cp =3D=3D ':')
 > +	    colon_seen =3D TRUE;
 >  	*cp =3D '\0';
 >=20
 >  	/*
 > @@ -1768,6 +1772,10 @@
 >      }
 >=20
 >  out:
 > +    if (paths && !colon_seen) {
 > +	Lst_Destroy(paths, NULL);
 > +	paths =3D NULL;
 > +    }
 >      assert(paths =3D=3D NULL);
 >      if (curTargs)
 >  	    Lst_Destroy(curTargs, NULL);
 >=20

From: Christos Zoulas <christos@zoulas.com>
To: "Simon J. Gerraty" <sjg@juniper.net>
Cc: gnats-bugs@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org,
 n54@gmx.com,
 "bsiegert@netbsd.org" <bsiegert@netbsd.org>
Subject: Re: bin/52737 (bmake crash for invalid usage of .PATH)
Date: Tue, 9 Apr 2019 10:45:07 -0700

 Yup, that should be great! Thanks!

 christos

 > On Apr 9, 2019, at 10:44 AM, Simon J. Gerraty <sjg@juniper.net> wrote:
 >=20
 > Christos Zoulas <christos@zoulas.com> wrote:
 >=20
 >> I'd rather unconditionally free "paths" if it was not NULL rather =
 than add more complexity
 >> to the code. This function needs to be split up; it is too big and =
 complicated.
 >=20
 > That works for me, so diff is then just:
 >=20
 > diff -r 6f103b9234c3 bmake/parse.c
 > --- a/bmake/parse.c	Sun Dec 30 09:28:02 2018 -0800
 > +++ b/bmake/parse.c	Tue Apr 09 10:42:04 2019 -0700
 > @@ -1768,7 +1768,8 @@
 >     }
 >=20
 > out:
 > -    assert(paths =3D=3D NULL);
 > +    if (paths)
 > +	Lst_Destroy(paths, NULL);
 >     if (curTargs)
 > 	    Lst_Destroy(curTargs, NULL);
 > }
 >=20
 >=20
 > --=20
 > This message has been 'sanitized'.  This means that potentially
 > dangerous content has been rewritten or removed.  The following
 > log describes which actions were taken.
 >=20
 > Sanitizer (start=3D"1554831880"):
 >  Split unusually long word(s) in header.
 >  SanitizeFile (filename=3D"unnamed.txt, =
 68181.1554831865.1@kaos.jnpr.net", mimetype=3D"text/plain"):
 >    Match (names=3D"unnamed.txt", rule=3D"9"):
 >      Enforced policy: accept
 >=20
 >  Total modifications so far: 1
 >=20
 >=20
 > Anomy 0.0.0 : Sanitizer.pm
 > $Id: Sanitizer.pm,v 1.94 2006/01/02 16:43:10 bre Exp $

From: "Simon J. Gerraty" <sjg@juniper.net>
To: Christos Zoulas <christos@zoulas.com>
Cc: <gnats-bugs@netbsd.org>, <gnats-admin@netbsd.org>,
        <netbsd-bugs@netbsd.org>, <n54@gmx.com>,
        "bsiegert@netbsd.org"
	<bsiegert@netbsd.org>, <sjg@juniper.net>
Subject: Re: bin/52737 (bmake crash for invalid usage of .PATH)
Date: Tue, 9 Apr 2019 10:44:25 -0700

 Christos Zoulas <christos@zoulas.com> wrote:

 > I'd rather unconditionally free "paths" if it was not NULL rather than a=
 dd more complexity
 > to the code. This function needs to be split up; it is too big and compl=
 icated.

 That works for me, so diff is then just:

 diff -r 6f103b9234c3 bmake/parse.c
 --- a/bmake/parse.c	Sun Dec 30 09:28:02 2018 -0800
 +++ b/bmake/parse.c	Tue Apr 09 10:42:04 2019 -0700
 @@ -1768,7 +1768,8 @@
      }
  =

  out:
 -    assert(paths =3D=3D NULL);
 +    if (paths)
 +	Lst_Destroy(paths, NULL);
      if (curTargs)
  	    Lst_Destroy(curTargs, NULL);
  }

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.