Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tr1/tests/thread is sporadically failing #1642

Closed
StephanTLavavej opened this issue Feb 12, 2021 · 7 comments
Closed

tr1/tests/thread is sporadically failing #1642

StephanTLavavej opened this issue Feb 12, 2021 · 7 comments
Labels
resolved Successfully resolved without a commit test Related to test code

Comments

@StephanTLavavej
Copy link
Member

#1627 encountered a sporadic failure in the legacy tr1 test suite. The failure log was:

Build setup steps:
Build steps:
Command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29812\bin\HostX64\x64\cl.EXE" "C:\a\1\s\tests\tr1\tests\thread\test.cpp" "-ID:\build\out\inc" "-IC:\a\1\s\tests\tr1\include" "-IC:\a\1\s\tests\std\include" "/nologo" "/Od" "/W4" "/w14061" "/w14242" "/w14265" "/w14582" "/w14583" "/w14587" "/w14588" "/w14749" "/w14841" "/w14842" "/w15038" "/w15214" "/w15215" "/w15216" "/w15217" "/sdl" "/WX" "/Zc:strictStrings" "/D_ENABLE_STL_INTERNAL_CHECK" "/bigobj" "/FIforce_include.hpp" "/D_ENFORCE_FACET_SPECIALIZATIONS=1" "/D_CRT_SECURE_NO_WARNINGS" "/Za" "/EHsc" "/MD" "/std:c++latest" "/permissive-" "-FeD:\build\tests\tr1\tests\thread\Output\14\thread.exe" "-link" "-LIBPATH:D:\build\out\lib\amd64" "-LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29812\lib\x64" "/MANIFEST:EMBED"
Exit Code: 0
Standard Output:
--
test.cpp

--

Intellisense response file steps:
Test setup steps:
Test steps:
Test step failed unexpectedly.
Command: "D:\build\tests\tr1\tests\thread\Output\14\thread.exe"
Exit Code: 1
Standard Output:
--
__STDCPP_THREADS__ = <1>

 GOT 0 != 1

 FAIL test 113 at line 336 in C:\a\1\s\tests\tr1\tests\thread\test.cpp: tgt <= STD chrono::system_clock::now() == true

FINISHED testing <thread>

***** 1 erroneous test cases in <thread> *****

***** 113 successful test cases in <thread> *****

#FAILED: <thread>

--

Code:

{
STD chrono::system_clock::duration dur = STD chrono::system_clock::duration(100);
STD chrono::system_clock::time_point tgt = STD chrono::system_clock::now() + dur;
STD this_thread::sleep_for(dur);
CHECK_INT(tgt <= STD chrono::system_clock::now(), true);
dur = -dur;
tgt = STD chrono::system_clock::now() + dur;
STD this_thread::sleep_for(dur);
CHECK_INT(tgt <= STD chrono::system_clock::now(), true);
}

Sporadic failures are doom. We should either fix this test to behave reliably, or skip it.

@StephanTLavavej StephanTLavavej added the test Related to test code label Feb 12, 2021
@CaseyCarter
Copy link
Member

Is this not simply a consequence of #718?

@StephanTLavavej
Copy link
Member Author

Failed again today, build 20210220.2.

@StephanTLavavej
Copy link
Member Author

And again in 20210220.6. 😾

@StephanTLavavej
Copy link
Member Author

And again in 20210222.7. 🙀

@StephanTLavavej
Copy link
Member Author

The test also contains data races / timing assumptions:

#define DELAY_VALUE 2 // milliseconds for delay()
namespace {
int called = 0;

void delay() { // pause, then mark that function was called
STD this_thread::sleep_for(STD chrono::milliseconds(DELAY_VALUE));
called = 1;
}

called = 0;
STD thread thr3(delay);
CHECK_INT(thr3.joinable(), true);
thr3.detach();
CHECK_INT(called, 0);

called is an ordinary int (not atomic, not protected by a lock), and this code assumes that the main thread can't possibly stall for 2 milliseconds between spawning thr3 and verifying that called is still 0.

@frederick-vs-ja
Copy link
Contributor

Is this issue fixed by #4457?

@StephanTLavavej StephanTLavavej added the resolved Successfully resolved without a commit label Aug 1, 2024
@StephanTLavavej
Copy link
Member Author

This was actually fixed by #2595 deleting the test completely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolved Successfully resolved without a commit test Related to test code
Projects
None yet
Development

No branches or pull requests

3 participants