On Tue, 9 Jan 2024 14:18:37 GMT, Jorn Vernee <jver...@openjdk.org> wrote:
> The issue with this test, and the test of JDK-8322324, seems to be that the > forked processes write to stderr/stdout, without this output being read > before the process terminates. The buffer might fill up if the output is not > being read, which means that the process will stall when writing (see stack > trace in JBS issue). > > `OutputAnalyzer` has ways to prevent this by continuously reading from the > output streams in separate threads, but because the current code calls > `Process::waitFor` before creating the `OutputAnalyzer`, we never actually > read the written output of the fork, which occasionally results in a stall > and subsequent timeout. > > The fix proposed by this patch is to use `ProcessTools::startProcess`, > instead of `ProcessBuilder::start`, which will also start the necessary > reader threads, preventing a stall. Incidentally, `startProcess` also has > built-in timeout handling which we can use. > > Testing: > - 500 runs of both java/foreign/TestStubAllocFailure.java and > java/foreign/critical/TestCriticalUpcall on various Windows x64 hosts (100 > iterations was enough to observe the failure twice). > - `jdk_foreign` suite. This pull request has now been integrated. Changeset: d2d58dd6 Author: Jorn Vernee <jver...@openjdk.org> URL: https://git.openjdk.org/jdk/commit/d2d58dd6a8ec366a4bc3eb12a253b252de24557e Stats: 16 lines in 1 file changed: 3 ins; 0 del; 13 mod 8322324: java/foreign/TestStubAllocFailure.java times out while waiting for forked process 8322637: java/foreign/critical/TestCriticalUpcall.java timed out Reviewed-by: mcimadamore ------------- PR: https://git.openjdk.org/jdk/pull/17324