From 530d5931b8ee4e9af54a1395334e644585608ae9 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 29 Aug 2026 05:16:47 +0100 Subject: [PATCH] test(engine): cover duplicate action locks Add a rule that declares the same lock twice and snapshot its timeout instead of the requested target. Acquiring the same non-reentrant mutex twice demonstrates the self-deadlock fixed by the following change. Signed-off-by: Rudi Grinberg --- .../test-cases/tests-locks.t/run.t | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/blackbox-tests/test-cases/tests-locks.t/run.t b/test/blackbox-tests/test-cases/tests-locks.t/run.t index 3c7bc9f8472..174ba05cb46 100644 --- a/test/blackbox-tests/test-cases/tests-locks.t/run.t +++ b/test/blackbox-tests/test-cases/tests-locks.t/run.t @@ -7,3 +7,20 @@ These tests are run without locks. They should end together (= expected) $ dune build --root=. -j 2 --diff-command=diff @all-tests-nolocks 2>&1 | > grep "^> *" | uniq -c | [ $(wc -l) -eq 1 ] && echo '=' || echo '<>' = + +Duplicate lock declarations currently deadlock a rule by making it acquire the same +non-reentrant mutex twice. + + $ mkdir duplicate-lock + $ cat >duplicate-lock/dune < (rule + > (target done) + > (locks same same) + > (action (write-file done done))) + > EOF + $ if $timeout 2 dune build --root=. duplicate-lock/done >/dev/null 2>&1; then + > cat _build/default/duplicate-lock/done + > else + > echo timed-out + > fi + timed-out