Control: tag -1 patch On Sat, Nov 30, 2013 at 09:17:11PM +0100, gregor herrmann wrote: > On Sat, 30 Nov 2013 17:33:15 +0100, David Suárez wrote: > > > > t/forked1.t ..... ok > > > # Looks like you planned 115 tests but ran 111. > > > print 26175: Connection reset by peer > > > Compilation failed in require at t/forked2.t line 5. > > > t/forked2.t ..... > > > Dubious, test returned 255 (wstat 65280, 0xff00) > > > Failed 4/115 subtests > > Now that's an intereting bug. > The tests still pass for me but take quite some long. So maybe we're > running into a timeout here, or some other fork problem on the amazon > build machine ...
What happens here is that - the test script forks, the parent sets up a TCP server and starts an event loop for clients - child connects there, sends test data and synchronizes on event indications from the parent - for every test data group, client disconnects when it has sent all the data and then makes a new connection for the next group - when the parent gets a new connection, it decrements its counter of tests left (in ie_connection()) - when the parent gets an EOF from a client connection, it exits if the test counter is zero (in ie_eof()) Now, it can happen that the client disconnect and the next connect both happen before the parent gets CPU time. In this case, the parent may get the 'new connection' event before the 'eof' event. This wouldn't matter otherwise, but if it's the last test group starting, ie_connection() decrements the counter to zero first, and ie_eof() thinks it's all done even though a new connection has just been accepted. The parent then does an exit(0) in ie_eof(), the child gets a connection reset, and an END block in the test libraries notices that there were too few tests and dies. The attached patch should fix it by making the client synchronize on the eof event from the parent before making a new connection. Will send it properly upstream once rt.cpan.org is up again. -- Niko Tyni nt...@debian.org
>From e11dc91080151bb59d73e72c3c0a3409c1b999ef Mon Sep 17 00:00:00 2001 From: Niko Tyni <nt...@debian.org> Date: Sat, 12 Dec 2015 11:33:34 +0200 Subject: [PATCH] Fix undeterministic test failures in t/forked2.t The parent process may get both the eof event from an old connection and the connect event from a new connection at the same time, and in an unpredictable order. If the connect event comes first, the handler may decrement the test counter to zero and make the eof handler think the testing is already over. Having the child synchronize on the eof event before making a new connection fixes this race. Bug-Debian: https://bugs.debian.org/730908 Bug: https://rt.cpan.org/Ticket/Display.html?id=92200 --- t/forked.tt | 1 + 1 file changed, 1 insertion(+) diff --git a/t/forked.tt b/t/forked.tt index e56c7fa..0d9ce18 100755 --- a/t/forked.tt +++ b/t/forked.tt @@ -265,6 +265,7 @@ if ($child = fork()) { } print "# CHILD closing\n"; close($s); + syncto("e"); } } else { die "fork: $!"; -- 2.6.2