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)
@@ -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
林峻頤
_______________________________________________
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to