Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src/usr.bin/make



Module Name:    src
Committed By:   rillig
Date:           Mon Oct  5 19:24:29 UTC 2020

Modified Files:
        src/usr.bin/make: Makefile arch.c compat.c cond.c dir.c enum.c for.c
            hash.c job.c main.c make.h make_malloc.c nonints.h parse.c str.c
            suff.c targ.c trace.c util.c var.c
        src/usr.bin/make/unit-tests: Makefile directive-export-literal.exp
            directive-export-literal.mk directive-ifndef.exp
            directive-ifndef.mk directive-ifnmake.exp directive-ifnmake.mk
            make-exported.exp make-exported.mk opt-debug-file.mk
            opt-debug-for.exp opt-debug-for.mk opt-debug-jobs.exp
            opt-debug-jobs.mk opt-debug-lint.exp opt-debug-lint.mk
            opt-debug-loud.exp opt-debug-loud.mk opt-debug.exp opt-debug.mk
            var-op-append.mk varname-dot-curdir.mk

Log Message:
make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25.  In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath.  Dir_ClearPath takes full ownership of the given list and
empties it.  This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table.  This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes.  This by itself
was not a problem since the hash table would be freed afterwards.  But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again.  Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/make/Makefile
cvs rdiff -u -r1.130 -r1.131 src/usr.bin/make/arch.c
cvs rdiff -u -r1.163 -r1.164 src/usr.bin/make/compat.c
cvs rdiff -u -r1.158 -r1.159 src/usr.bin/make/cond.c
cvs rdiff -u -r1.156 -r1.157 src/usr.bin/make/dir.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/enum.c
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/make/for.c
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/make/hash.c
cvs rdiff -u -r1.258 -r1.259 src/usr.bin/make/job.c
cvs rdiff -u -r1.367 -r1.368 src/usr.bin/make/main.c
cvs rdiff -u -r1.153 -r1.154 src/usr.bin/make/make.h
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/make_malloc.c
cvs rdiff -u -r1.138 -r1.139 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.366 -r1.367 src/usr.bin/make/parse.c
cvs rdiff -u -r1.66 -r1.67 src/usr.bin/make/str.c
cvs rdiff -u -r1.174 -r1.175 src/usr.bin/make/suff.c
cvs rdiff -u -r1.109 -r1.110 src/usr.bin/make/targ.c
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/trace.c
cvs rdiff -u -r1.61 -r1.62 src/usr.bin/make/util.c
cvs rdiff -u -r1.565 -r1.566 src/usr.bin/make/var.c
cvs rdiff -u -r1.160 -r1.161 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.2 -r1.3 \
    src/usr.bin/make/unit-tests/directive-export-literal.exp \
    src/usr.bin/make/unit-tests/directive-ifndef.exp \
    src/usr.bin/make/unit-tests/directive-ifnmake.exp \
    src/usr.bin/make/unit-tests/opt-debug-file.mk \
    src/usr.bin/make/unit-tests/opt-debug-for.exp \
    src/usr.bin/make/unit-tests/opt-debug-for.mk \
    src/usr.bin/make/unit-tests/opt-debug-jobs.exp \
    src/usr.bin/make/unit-tests/opt-debug-jobs.mk \
    src/usr.bin/make/unit-tests/opt-debug-loud.exp \
    src/usr.bin/make/unit-tests/opt-debug-loud.mk \
    src/usr.bin/make/unit-tests/opt-debug.exp
cvs rdiff -u -r1.3 -r1.4 \
    src/usr.bin/make/unit-tests/directive-export-literal.mk \
    src/usr.bin/make/unit-tests/directive-ifndef.mk \
    src/usr.bin/make/unit-tests/directive-ifnmake.mk \
    src/usr.bin/make/unit-tests/make-exported.exp \
    src/usr.bin/make/unit-tests/opt-debug.mk \
    src/usr.bin/make/unit-tests/var-op-append.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/make-exported.mk \
    src/usr.bin/make/unit-tests/varname-dot-curdir.mk
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/opt-debug-lint.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/opt-debug-lint.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index