threading.WaitForMultipleObjectsEx.test2 failed on CentOS7.1
http://dotnet-ci.cloudapp.net/job/dotnet_coreclr/job/master/job/checked_centos7.1/1435/testReport/threading/WaitForMultipleObjectsEx/test2/
This happened on July 9 in a test job on merged code. Worth some investigation (FWIW, I'm only seeing this 1 failure for this test).
Output from the test:
MESSAGE: Expected thread to wait for 1000 ms (and not get interrupted). Interrupt Time: 500 ms, ThreadWaitDelta 771 +++++++++++++++++++ STACK TRACE:
@wtgodbe Did this repro again?
CC @kouvel
Looks like this is still repro-ing occasionally: https://ci.dot.net/job/dotnet_coreclr/job/master/job/checked_centos7.1/1302/testReport/threading/WaitForMultipleObjectsEx/test2/
@sergiy-k @adityamandaleeka @jkotas who owns PAL tests these days?
Probably me for the threading ones, I'll take a look
@wtgodbe - me for the rest of the PAL tests.
failed again in job: runtime-coreclr ilasm 20200919.1
failed test: threading.WaitForMultipleObjectsEx.test2
CoreCLR Linux arm64 Checked ilasmroundtrip @ (Ubuntu.1804.Arm64.Open)[email protected]/dotnet-buildtools/prereqs:ubuntu-18.04-helix-arm64v8-a45aeeb-20190620155855
Error message
Expected thread to wait for 1000 ms (and get interrupted).
Interrupt Time: 500 ms, ThreadWaitDelta 499
Stack trace
failed again in job: runtime-coreclr jitstress2-jitstressregs 20201004.1
failed test: threading.WaitForMultipleObjectsEx.test2
CoreCLR Linux arm64 Checked jitstress2_jitstressregs3 @ (Ubuntu.1804.Arm64.Open)[email protected]/dotnet-buildtools/prereqs:ubuntu-18.04-helix-arm64v8-a45aeeb-20190620155855
Error message
Expected thread to wait for 1000 ms (and get interrupted).
Interrupt Time: 500 ms, ThreadWaitDelta 499
Stack trace
The current error is really strange. The check in the code looks like this: https://github.com/dotnet/runtime/blob/59bb74c9ecc743a35ef5401f5b2baf2f44e986f2/src/coreclr/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/test2.cpp#L57-L65
From the message above, the values of the variables were: ChildThreadWaitTime = 1000 InterruptTime = 500 ThreadWaitDelta_WFMO_test2 = 499
The TOLERANCE is defined as 10. So the condition with replaced variables by values looks like
((499 >= 1000) && (499 - 1000) > 10)
|| (( 499 < 500) && (499 - 500) > 10)
So this condition should have been evaluated as false and the error message should not have been printed.
That means that there is likely a write visibility problem (the ThreadWaitDelta_WFMO_test2 is set by a secondary thread, but read on the main thread) or the compiler moved reading the ThreadWaitDelta_WFMO_test2 to some point before the secondary thread completed.
Actually, I've checked the types of the three variables and they are all unsigned! So 499-500 is not -1, but 0xffffffff, which is obviously > 10. That explains why the test goes the failure path. And I've also realized that the second part of the condition is wrong, it first tests if the ThreadWaitDelta_WFMO_test2 is less than the InterruptTime and then checks if the ThreadWaitDelta_WFMO_test2 - InterruptTime, which would always be <= 0, is larger than the TOLERANCE. So it is a test bug. The subtraction should be reversed. The test should pass as the 1ms delta is within the tolerance.