When terminating my program, the many components join their threads and this particular one gives me an access violation when joined along with other components at the same time.
The code is simple – We just join.
void ScriptManager::initialize(int segment_number)
{
_thread = std::thread(&ScriptManager::start, this);
}
void ScriptManager::finalize(int segment_number)
{
//if (_thread.joinable())
try {
_thread.join();
} catch(std::exception &e) {
HLog(error) << "ScriptManager::finalize: " << e.what();
}
//
//_script_files.clear();
//
//bool value = _is_initialized;
//_is_initialized.compare_exchange_strong(value, false);
}
The program runs but at the end we receive an access violation –
Exception thrown at 0x00007FFA63663FAA (ntdll.dll) in ZoneSystemTest.exe: 0xC0000005: Access violation writing location 0x0000000000000024.
Would anyone know as to what would be the reason? Could it be that the influence of another thread makes this variable non-writable? There were no exceptions caught, only thrown. When commenting this line, there is no violation, so I know it is because the _thread
member variable is responsible for it.