私はこの単純なテストプログラムを作成しましたが、デバッグブレークがトリガーされたり、クラッシュしたりすることがあります(Debug / Win32 / VS2010SP1の下で)。もちろん、動作することもあります。私が間違っていることはありますか、それともPPL(VS2010)のどこかにバグがありますか?
#include "stdafx.h"
#include <ppl.h>
#include <vector>
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<int> vi;
Concurrency::critical_section cs;
Concurrency::parallel_for(0, 10000, [&](int i)
{
Concurrency::critical_section::scoped_lock l(cs);
vi.push_back(i);
});
return 0;
}
DebugBreak呼び出しスタックは次のようになります。
msvcr100d.dll!_CrtDbgBreak()行85 C msvcr100d.dll!_VCrtDbgReportW(int nRptType = 2、const wchar_t * szFile = 0x0f45d230、int nLine = 728、const wchar_t * szModule = 0x00000000、const wchar_t * s = 0x7d92f7c4)行502 C msvcr100d.dll!_CrtDbgReportWV(int nRptType = 2、const wchar_t * szFile = 0x0f45d230、int nLine = 728、const wchar_t * szModule = 0x00000000、const wchar_t * szFormat = 0x0f 241+0x1dバイトC++msvcr100d.dll!_CrtDbgReportW(int nRptType = 2、const wchar_t * szFile = 0x0f45d230、int nLine = 728、const wchar_t * szModule = 0x00000000、const wchar_t * szFormat = 0x0f45d400、...バイトC++msvcr100d.dll!Concurrency :: details :: LockQueueNode :: Copy(Concurrency :: details ::LockQueueNode * pCopyFromNode = 0x7d92f908)728行目+0x27バイトC++ msvcr100d.dll! :scoped_lock(Concurrency ::critical_section&_Critical_section = locked)行1083 C ++ Lockable.exe!
anonymous namespace'::<lambda0>::operator()(int i=1418) Line 14 + 0x11 bytes C++ Lockable.exe!Concurrency::_Parallel_chunk_helper_invoke<int,unsigned int,
匿名名前空間'::、0> :: _ Invoke(const int&_First = 0、unsigned int&_Index = 1418、constanonymous-namespace'::<lambda0> & _Func={...}) Line 1445 C++ Lockable.exe!Concurrency::_Parallel_chunk_helper<int,unsigned int,
匿名名前空間'::、0> :: operator()()行1781+0x16バイトC++Lockable.exe!Concurrency :: task_handle、0 >>>(Concurrency :: task_handle、0 >> * _PChore = 0x7c13fba8 {_M_first = 0 _M_step = 1 _M_function = {...} ...})3495行目C ++ msvcr100d.dll!Concurrency :: details :: _ UnrealizedChore :: _ StructuredChoreWrapper(Concurrency :: details :: _ UnrealizedChore * pChore = 0x7c13fba8 {_M_first = 0 _M_step = 1 _M_function = {...} ...})99行目+0xcバイトC++ msvcr100d.dll!Concurrency :: details :: _ UnrealizedChore :: _ Invoke()3454行目+0xcバイトC++ msvcr100d.dll!Concurrency :: details :: WorkItem :: Invoke()75行目C ++ msvcr100d.dll!Concurrency :: details :: InternalContextBase :: ExecuteChoreInline(Concurrency :: details :: WorkItem * pWork = 0x7d92fe7c)1385行目C ++ msvcr100d.dll!Concurrency :: details: :InternalContextBase ::Dispatch(Concurrency :: DispatchState * pDispatchState = 0x7d92fe9c)Line 1478 C ++ msvcr100d.dll!Concurrency :: details :: FreeThreadProxy :: Dispatch()Line 157 C ++ msvcr100d.dll!Concurrency :: details :: ThreadProxy :: ThreadProxyMain(void * lpParameter = 0x2ed5b4f0)行162 C ++ kernel32.dll!763c33aa()
[以下のフレームが正しくないか、欠落している可能性があります。kernel32.dllのシンボルがロードされていません]
ntdll.dll!771a9ef2()
ntdll.dll!771a9ec5()
私がちょうど持っている1つのクラッシュは、ロックが保持されていないように見えます(cs:not_locked)
Lockable.exe!std :: vector> :: _ Orphan_range(int * _First = 0x0000c5db、int * _Last = 0x0000c5db)行1442+0x5バイトC++Lockable.exe!std :: vector> :: push_back(const int&_Val = 4177 )995行目C ++
Lockable.exe!
anonymous namespace'::<lambda0>::operator()(int i=4177) Line 16 C++ Lockable.exe!Concurrency::_Parallel_chunk_helper_invoke<int,unsigned int,
匿名名前空間'::、0> :: _ Invoke(const int&_First = 0、unsigned int&_Index = 4177、constanonymous-namespace'::<lambda0> & _Func={...}) Line 1445 C++ Lockable.exe!Concurrency::_Parallel_chunk_helper<int,unsigned int,
匿名名前空間'::、0> :: operator()()行1833+0x16バイトC++Lockable.exe!Concurrency :: task_handle、0 >>>(Concurrency :: task_handle、0 >> * _PChore = 0x7cbffc24 {_M_first = 0 _M_step = 1 _M_function = {...} ...})3495行目C ++ msvcr100d.dll!Concurrency :: details :: _ UnrealizedChore :: _ StructuredChoreWrapper(Concurrency :: details :: _ UnrealizedChore * pChore = 0x7cbffc24 {_M_first = 0 _M_step = 1 _M_function = {...} ...})99行目+0xcバイトC++ msvcr100d.dll!Concurrency :: details :: _ UnrealizedChore :: _ Invoke()3454行目+0xcバイトC++ msvcr100d.dll!Concurrency :: details :: WorkItem :: Invoke()75行目C ++ msvcr100d.dll!Concurrency :: details :: InternalContextBase :: ExecuteChoreInline(Concurrency :: details :: WorkItem * pWork = 0x7bc0fab4)1385行目C ++ msvcr100d.dll!Concurrency :: details: :InternalContextBase ::Dispatch(Concurrency :: DispatchState * pDispatchState = 0x7bc0fad4)Line 1478 C ++ msvcr100d.dll!Concurrency :: details :: FreeThreadProxy :: Dispatch()Line 157 C ++ msvcr100d.dll!Concurrency :: details :: ThreadProxy :: ThreadProxyMain(void * lpParameter = 0x2dcf6200)行162 C ++ kernel32.dll!763c33aa()
[以下のフレームが正しくないか、欠落している可能性があります。kernel32.dllのシンボルがロードされていません]
ntdll.dll!771a9ef2()
ntdll.dll!771a9ec5()
また、PPLの内部実装内でも、他のランダムアクセス違反が発生する可能性があります。これは再現できると思います。(うまくいけば)
Visual Studio 2012 Express for Desktopで同じプログラムを実行しましたが、多くのテストを実行した後、すべてが正常に機能しているようです。
VS2010でのPPLが実稼働環境で使用するにはバグがあるのではないかと思いますか?
入力ありがとうございます!