General Category > General Discussion about just::thread

call to future::wait() aborts the program

(1/2) > >>

oleg@completedb.com:
System has 24 logical processors
Compiled under Visual Studio 2012 x64

The same code below runs fine using native Microsoft implementation and fails most of the time when using just::threads
The exact place where it fails is on ftr.wait()
Please advise

   for (unsigned i = 0; i < 10; i++)
   {
      const unsigned THREAD_COUNT = thread::hardware_concurrency() - 1;
      const unsigned SECOND_COUNT = 1;
      volatile bool runThreads = true;
      vector<future<long long>> results;
      for (unsigned u = 0; u < THREAD_COUNT; u++)
      {
         results.emplace_back ( async( [&] ()
         {
            long long counter = 0;
            while (runThreads)
            {
               counter++;
            }
            return counter; 
         } ) );
      }
      this_thread::sleep_for(chrono::seconds(SECOND_COUNT));
      runThreads = false;
      long long total = 0;
      for (auto& ftr : results)
      {
         ftr.wait();
         total += ftr.get();
      }
      cout << total << cout << endl;
   }

Anthony Williams:
I am sorry to hear that you are experiencing problems.

What OS are you running? Which build of VS2012 are you using? (Open a VS2012 command prompt and type "cl") What compiler options are you using?

I cannot reproduce the problem on Windows 7 x64 with VS 2012, build 17.00.50727.1, on a 6-core machine.

I don't have access to a 24-core system just now, but I do have an 8-core one (also running Windows 7). I don't see that the number of cores should make a difference, but I'll try it out in case it does.

oleg@completedb.com:
OS: Windows 8 Pro
Processors: 2 x Intel Xeon E5-2620
Logical Cores: 24
RAM: 64 GB
Microsoft Visual Studio Professional 2012: Version 11.0.60315.01 Update 2
Build: 17.00.60315.1

C++ Command Line:
/Yu"stdafx.h" /GS /GL /W3 /Gy /Zc:wchar_t /I"C:\Program Files (x86)\JustSoftwareSolutions\JustThread\include" /Zi /Gm- /O2 /sdl /Fd"x64\Release\vc110.pdb" /fp:precise /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /Fa"x64\Release\" /EHsc /nologo /Fo"x64\Release\" /Fp"x64\Release\FutureWaitFailed.pch"

For some reason I can not attach the file, wanted to send you Visual Studio solution with source files. If you do not mind I will email it. Its small.
If you run it do not forget to change include and lib path to just thread as on my system it maybe in a different place

oleg@completedb.com:
Sorry forgot to mention it works on Win32 only fails on x64

Anthony Williams:
Thank you for the information. I am attempting to recreate the problem.

Navigation

[0] Message Index

[#] Next page

Go to full version