Bug 190100 - [patch] make(1): fix core dumps at syntax error
Summary: [patch] make(1): fix core dumps at syntax error
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 9.2-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
Depends on:
Reported: 2014-05-22 11:10 UTC by lampa
Modified: 2017-12-31 22:23 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description lampa 2014-05-22 11:10:00 UTC
make core dumps with this invalid Makefile (notice two && operators):

. if ${OSVERSION} >= 901500 && && (${ARCH} == i386 || ${ARCH} == amd64)
. endif

(gdb) where
#0  0x0000000000448d8c in kill ()
#1  0x0000000000447bd8 in abort ()
#2  0x0000000000403197 in Cond_If (
    line=0x80085de05 "${OSVERSION} >= 901500 && && (${ARCH} == i386 || ${ARCH} == amd64)", code=<value optimized out>, lineno=2)
    at /usr/src/usr.bin/make/cond.c:1079
#3  0x000000000040d64c in Parse_File (name=<value optimized out>,
    stream=<value optimized out>) at /usr/src/usr.bin/make/parse.c:2366
#4  0x000000000040a274 in ReadMakefile (p=<value optimized out>)
    at /usr/src/usr.bin/make/main.c:323
#5  0x000000000040a328 in TryReadMakefile (p=0x80081a1b0 "Makefile")
    at /usr/src/usr.bin/make/main.c:342
#6  0x000000000040a879 in main (argc=3, argv=0x7fffffffea90)
    at /usr/src/usr.bin/make/main.c:1185

It seems that current token from CondE(TRUE) is And and this is not handled correctly in switch() at line 1061. Perhaps any unexpected token can be here?


remove default: block and change case Err: to default:

      switch (CondE(TRUE)) {
          case True:
                if (CondToken(TRUE) != EndOfFile)
                        goto err;
                value = TRUE;

          case False:
                if (CondToken(TRUE) != EndOfFile)
                        goto err;
                value = FALSE;

  err:          Parse_Error(PARSE_FATAL, "Malformed conditional (%s)", line);


With this change it correctly reports:

"Makefile", line 2: Malformed conditional ...
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:26 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped