From owner-freebsd-current@freebsd.org Mon Feb 27 10:11:07 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 79F96CE9C62 for ; Mon, 27 Feb 2017 10:11:07 +0000 (UTC) (envelope-from iblis@hs.ntnu.edu.tw) Received: from mail.hs.ntnu.edu.tw (mail.hs.ntnu.edu.tw [140.131.149.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B127DC1 for ; Mon, 27 Feb 2017 10:11:06 +0000 (UTC) (envelope-from iblis@hs.ntnu.edu.tw) Received: by mail.hs.ntnu.edu.tw (Postfix, from userid 800) id E87741C648F; Mon, 27 Feb 2017 18:10:52 +0800 (CST) Received: from abeing (IP-215-9.cs.nctu.edu.tw [140.113.215.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: iblis@hs.ntnu.edu.tw) by mail.hs.ntnu.edu.tw (Postfix) with ESMTPSA id CCD501C6444 for ; Mon, 27 Feb 2017 18:10:52 +0800 (CST) Date: Mon, 27 Feb 2017 18:10:44 +0800 From: Iblis Lin To: freebsd-current@freebsd.org Subject: bmake core dump Message-ID: <20170227101044.GB31394@abeing> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.7.1 (2016-10-04) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000466, version=1.2.4 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Feb 2017 10:11:07 -0000 Hi, I encounted core dump with `make -f - ...` The backtrace: Core was generated by `/usr/bin/make -f - -V MAKE_JOBS_NUMBER'. Program terminated with signal 10, Bus error. #0 Hash_FindEntry (t=, key=) at /usr/src/contrib/bmake/hash.c:231 231 if (e->namehash == h && strcmp(e->name, p) == 0) (gdb) bt #0 Hash_FindEntry (t=, key=) at /usr/src/contrib/bmake/hash.c:231 #1 0x0000000000419fd4 in VarFind (name=, ctxt=0x800a0d180, flags=7) at /usr/src/contrib/bmake/var.c:417 #2 0x000000000041a504 in Var_Exists (name=, ctxt=0x800a0d180) at /usr/src/contrib/bmake/var.c:1117 #3 0x0000000000412222 in Parse_DoVar (line=, ctxt=) at /usr/src/contrib/bmake/parse.c:1891 #4 0x0000000000413927 in Parse_File (name=, fd=) at /usr/src/contrib/bmake/parse.c:3085 #5 0x000000000040cc21 in ReadMakefile (p=0x7fffffffe9c9, q=) at /usr/src/contrib/bmake/main.c:1474 #6 0x000000000040cdd9 in ReadAllMakefiles (p=, q=) at /usr/src/contrib/bmake/main.c:762 #7 0x000000000041ee7a in Lst_FindFrom (l=, ln=, d=, cProc=) at /usr/src/contrib/bmake/lst.lib/lstFindFrom.c:83 #8 0x000000000040c1c0 in main (argc=5, argv=) at /usr/src/contrib/bmake/main.c:1239 #9 0x000000000040035f in _start () #10 0x0000000000000000 in ?? () Current language: auto; currently minimal And hope this patch help: Index: contrib/bmake/parse.c =================================================================== --- contrib/bmake/parse.c (revision 309367) +++ contrib/bmake/parse.c (working copy) @@ -572,7 +572,7 @@ bufpos += result; } assert(bufpos <= lf->len); - lf->len = bufpos; + lf->len = bufpos + 1; /* truncate malloc region to actual length (maybe not useful) */ if (lf->len > 0) { @@ -579,6 +579,9 @@ lf->buf = bmake_realloc(lf->buf, lf->len); } + /* read() do not add the null byte character */ + *(lf->buf + lf->len - 1) = '\0'; + #ifdef HAVE_MMAP done: #endif -- Iblis Lin 林峻頤