我使用VS2012,我不能執行我的程序中沒有崩潰的線程。應該指出,我的程序包含OpenGL和SOIL。C + + std ::線程在執行時崩潰
我只需撥打一個空白的線程,沒有語句的功能,在我的功能之一,它立即崩潰:
void service(){
}
/* Connect to server */
void connectToServer(){
cout << "~CLIENT~\n" << endl;
std::thread serverConnect(service);
}
當程序調用connectToServer()
它打破在調用語句std::thread serverConnect(service);
通過以下調用-stack:
msvcr110.dll!_crt_debugger_hook(int _Reserved) Line 60 C
msvcr110.dll!_call_reportfault(int nDbgHookCode, unsigned long dwExceptionCode, unsigned long dwExceptionFlags) Line 152 C++
msvcr110.dll!abort() Line 90 C
msvcr110.dll!terminate() Line 96 C++
IRC.exe!connectToServer() Line 449 C++
IRC.exe!handleKeypress(unsigned char key, int x, int y) Line 936 C++
glut32.dll!1000e054() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for glut32.dll]
glut32.dll!1000d5de() Unknown
user32.dll!753962fa() Unknown
user32.dll!75396d3a() Unknown
user32.dll!75396ce9() Unknown
user32.dll!753a0d27() Unknown
user32.dll!753a0d4d() Unknown
opengl32.dll!18f160fb() Unknown
user32.dll!753962fa() Unknown
user32.dll!75396d3a() Unknown
user32.dll!75396ce9() Unknown
user32.dll!753977c4() Unknown
user32.dll!753bd62a() Unknown
user32.dll!75397bca() Unknown
glut32.dll!10004970() Unknown
glut32.dll!10004a7a() Unknown
glut32.dll!1000491f() Unknown
IRC.exe!main(int argc, char * * argv) Line 1683 C++
IRC.exe!__tmainCRTStartup() Line 536 C
kernel32.dll!7551338a() Unknown
ntdll.dll!77049f72() Unknown
ntdll.dll!77049f45() Unknown
該程序在沒有線程調用語句的情況下工作正常。另外,我的VS環境具有運行簡單的示例線程的程序是這樣一個沒有問題:
#include <iostream>
#include <thread>
using namespace std;
//This function will be called from a thread
void call_from_thread() {
std::cout << "Hello, World" << std::endl;
}
int main() {
//Launch a thread
thread t1(call_from_thread);
system("pause");
return 0;
}
只有當我在程序崩潰使用線程。
您是否加入()線程? – 2014-08-29 00:21:49