I run my game on linux system of TV, when I exit game, the system will crash.
from the output log, I know my game has been quite, but system crash following.
the main function like below:
int main(int argc, char** argv)
{
......
SDL_Quit();
printf("Log: exit end. \n);// it's printed on console
return 0;
}
I can find the output log about Log: exit end. So the game has been exit right?
I found the game exit will only crash after create threads.
Here is the run function in thread below:
while ( pThread->m_running )
{
string str;
string cmdStr;
if ( pThread->GetSendMsg(str, cmdStr) )
{
string returnStr = Connection::DealHttpSendMsg( str, cmdStr );
pThread->AddReturnMsg( returnStr );
haveData = true;
}
else
{
SDL_Delay(100);
haveData = false;
}
}
My question is that if the m_running is alway true. so when I exit the game, the thread is still running. Will it cause the crash?
It will if that thread tries to access resources that are being simultaneously destroyed by the main thread.
Just quitting the app won’t crash it if you have a worker thread that does nothing.