Crash when exiting app while pingBestRegion() is in progress

I am seeing a crash when exiting the application while LoadBalancing::Client::pingBestRegion() is in progress. This can be reproduced with demo_windows_loadBalancing by quitting during pingBestRegion(). The demo needs to be changed first to ping the servers by changing the line:

static const bool useBestRegion = true;

Call stack:
Exception thrown at 0x00BB174D in demo_windows_loadBalancing_vc14.exe: 0xC0000005: Access violation writing location 0x016536AC.

 	demo_windows_loadBalancing_vc14.exe!ExitGames::Common::MemoryManagement::allocateArray<unsigned char>(unsigned int count) Line 318	C++
 	demo_windows_loadBalancing_vc14.exe!ExitGames::Photon::Internal::EnetConnect::recvBuffer(unsigned char * * ppBuff, int * pBytesRead) Line 46	C++
 	demo_windows_loadBalancing_vc14.exe!ExitGames::Photon::Internal::SocketConnect::service() Line 172	C++
 	demo_windows_loadBalancing_vc14.exe!ExitGames::Photon::Internal::PeerBase::pingServer(void * pArg) Line 315	C++
 	demo_windows_loadBalancing_vc14.exe!ExitGames::Common::Helpers::Thread::startRoutine(void * pArg) Line 105	C++

This happens on Windows but also causes a crash on Android 10 due to the threads not being destroyed.
  #00  pc 000000000006f06c  /apex/com.android.runtime/lib64/bionic/libc.so (abort+160)
  #01  pc 00000000000500fc  /system/lib64/libc++.so (abort_message+232)
  #02  pc 0000000000050218  /system/lib64/libc++.so (demangling_terminate_handler()+44)
  #03  pc 00000000000646c4  /system/lib64/libc++.so (std::__terminate(void (*)())+12)
  #04  pc 000000000006466c  /system/lib64/libc++.so (std::terminate()+52)
  #05  pc 00000000000bb150  /system/lib64/libc++.so (std::__1::thread::~thread()+20)
  #06  pc 00000000000d0f48  /apex/com.android.runtime/lib64/bionic/libc.so (__cxa_finalize+212)
  #07  pc 00000000000cc930  /apex/com.android.runtime/lib64/bionic/libc.so (exit+24)

also:
  #00  pc 0000000000083134  /apex/com.android.runtime/lib64/bionic/libc.so (abort+160)
  #01  pc 00000000000e3e4c  /apex/com.android.runtime/lib64/bionic/libc.so (__fortify_fatal(char const*, ...)+116)
  #02  pc 00000000000e3580  /apex/com.android.runtime/lib64/bionic/libc.so (HandleUsingDestroyedMutex(pthread_mutex_t*, char const*)+52)
  #03  pc 00000000000e3dc4  /apex/com.android.runtime/lib64/bionic/libc.so (pthread_mutex_destroy+140)
  #04  pc 00000000000afbd8  /system/lib64/libc++.so (std::__1::mutex::~mutex()+8)
  #05  pc 00000000000e5678  /apex/com.android.runtime/lib64/bionic/libc.so (__cxa_finalize+212)
  #06  pc 00000000000e1060  /apex/com.android.runtime/lib64/bionic/libc.so (exit+24)
Sign In or Register to comment.