bmake core dump

From: Iblis Lin <iblis_at_hs.ntnu.edu.tw>
Date: Mon, 27 Feb 2017 18:10:44 +0800
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=<value optimized out>, key=<value optimized out>) at /usr/src/contrib/bmake/hash.c:231
231                     if (e->namehash == h && strcmp(e->name, p) == 0)
(gdb) bt
#0  Hash_FindEntry (t=<value optimized out>, key=<value optimized out>) at /usr/src/contrib/bmake/hash.c:231
#1  0x0000000000419fd4 in VarFind (name=<value optimized out>, ctxt=0x800a0d180, flags=7) at /usr/src/contrib/bmake/var.c:417
#2  0x000000000041a504 in Var_Exists (name=<value optimized out>, ctxt=0x800a0d180) at /usr/src/contrib/bmake/var.c:1117
#3  0x0000000000412222 in Parse_DoVar (line=<value optimized out>, ctxt=<value optimized out>)
    at /usr/src/contrib/bmake/parse.c:1891
#4  0x0000000000413927 in Parse_File (name=<value optimized out>, fd=<value optimized out>)
    at /usr/src/contrib/bmake/parse.c:3085
#5  0x000000000040cc21 in ReadMakefile (p=0x7fffffffe9c9, q=<value optimized out>) at /usr/src/contrib/bmake/main.c:1474
#6  0x000000000040cdd9 in ReadAllMakefiles (p=<value optimized out>, q=<value optimized out>)
    at /usr/src/contrib/bmake/main.c:762
#7  0x000000000041ee7a in Lst_FindFrom (l=<value optimized out>, ln=<value optimized out>, d=<value optimized out>,
    cProc=<value optimized out>) at /usr/src/contrib/bmake/lst.lib/lstFindFrom.c:83
#8  0x000000000040c1c0 in main (argc=5, argv=<value optimized out>) 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)
_at__at_ -572,7 +572,7 _at__at_
 		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) {
_at__at_ -579,6 +579,9 _at__at_
 		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
林峻頤
Received on Mon Feb 27 2017 - 09:11:07 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:10 UTC