From: Stefano Lattarini Date: Wed, 10 Aug 2011 13:37:27 +0000 (+0200) Subject: test harness: avoid possible fork bomb X-Git-Tag: ng-0.5a~89^2~101^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fff2880a5e284f17cd6f0d869b0addeef7e1f55;p=thirdparty%2Fautomake.git test harness: avoid possible fork bomb This fixes a regression w.r.t. the master branch, exposed by test 'parallel-tests-fork-bomb.test'. * lib/am/check.am (am--redo-logs): Detect possible infinite recursion due to a test log in $(TEST_LOGS) being the same as $(TEST_SUITE_LOG). * tests/parallel-tests-fork-bomb.test: Enhance and extend a little now that we have more explicit semantics. --- diff --git a/ChangeLog b/ChangeLog index 76e1b3dd2..4e50d370a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-08-09 Stefano Lattarini + + test harness: avoid possible fork bomb + This fixes a regression w.r.t. the master branch, exposed by + test 'parallel-tests-fork-bomb.test'. + * lib/am/check.am (am--redo-logs): Detect possible infinite + recursion due to a test log in $(TEST_LOGS) being the same + as $(TEST_SUITE_LOG). + * tests/parallel-tests-fork-bomb.test: Enhance and extend a + little now that we have more explicit semantics. + 2011-08-09 Stefano Lattarini coverage: possible infinite recursion in the test harness diff --git a/lib/Automake/tests/Makefile.in b/lib/Automake/tests/Makefile.in index c898f49cc..aca691c99 100644 --- a/lib/Automake/tests/Makefile.in +++ b/lib/Automake/tests/Makefile.in @@ -352,7 +352,12 @@ cscope cscopelist: am--redo-logs: @rm -f $$redo_logs @rm -f $$redo_results - @$(MAKE) $(AM_MAKEFLAGS) $$redo_logs + @if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + else \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; @st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ diff --git a/lib/am/check.am b/lib/am/check.am index 76c5273b8..27388df02 100644 --- a/lib/am/check.am +++ b/lib/am/check.am @@ -132,7 +132,16 @@ am__set_TESTS_bases = \ am--redo-logs: @rm -f $$redo_logs @rm -f $$redo_results - @$(MAKE) $(AM_MAKEFLAGS) $$redo_logs +## The use of the `am__remaking_logs' environment variable below is +## required to ensure that we don't go into an infinite recursion in +## case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG). +## Yes, this has already happened in practice. Sigh! + @if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + else \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; ## Sanity check: each unreadable or non-existent test result file should ## has been properly remade at this point, as should the corresponding log ## file. diff --git a/tests/Makefile.in b/tests/Makefile.in index 1688557a6..9e03806f4 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -1508,7 +1508,12 @@ cscope cscopelist: am--redo-logs: @rm -f $$redo_logs @rm -f $$redo_results - @$(MAKE) $(AM_MAKEFLAGS) $$redo_logs + @if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + else \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; @st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \