From 58318af71844c71db1621706d1f6a7bbed8e8621 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 2 Sep 2019 18:01:13 +0200 Subject: [PATCH] jobwait(): fix race if job exits before waiting on it Problem: If a job exits while waiting on another job, the on_exit handler is queued but f_jobwait() skips it. Solution: Always do process_wait(), so that handlers are run during f_jobwait(). fix #8302 Test case: $ BUSTED_ARGS="--repeat=2000 --no-keep-going" TEST_FILE=test/functional/core/job_spec.lua TEST_FILTER=waiting make functionaltest Failure example (macOS CI): FAILED test/functional/core/job_spec.lua: jobs jobwait will run callbacks while waiting test/functional/core/job_spec.lua:606: Expected objects to be the same. Passed in: (table: 0x1be77c80) { [1] = 'notification' [2] = 'wait' *[3] = { *[1] = 3 } } Expected: (table: 0x1be77d10) { [1] = 'notification' [2] = 'wait' *[3] = { *[1] = 4 } } stack traceback: test/functional/core/job_spec.lua:606: in function stream.proc.status >= 0) { + if (jobs[i] == NULL) { continue; } diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index dec7c1422d..3a1be7bc52 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -607,7 +607,6 @@ describe('jobs', function() \ ]) call rpcnotify(g:channel, 'wait', sort(g:jobs), sort(g:exits)) ]]) - assert:set_parameter('TableFormatLevel', 1000000) eq({'notification', 'wait', {{3,4,5,6}, {3,4,5,6}}}, next_msg()) end)