mirror of
https://github.com/ARMSX2/ARMSX3.git
synced 2026-08-24 16:58:52 -07:00
get_cycles passes the pthread handle to pthread_getcpuclockid, which glibc answers with an error for a thread that has already exited -- the else branch below returns the last known value for exactly that case. bionic instead looks the handle up in its list of live threads and aborts the process when it is not there. m_thread is never cleared when a thread ends and the performance overlay samples every PPU, SPU and RSX thread on a timer, so one finished thread is enough to take the emulator down with it. Latent here rather than absent: it needs the overlay on and a thread to have gone. Record the kernel tid at initialize and build the per-thread clock id from it the way bionic does once its own lookup succeeds, so clock_gettime simply fails for a dead thread, which is what the surrounding code already expects. Cleared at finalize so a thread stops being sampled before it goes away. Other platforms keep the original path. Found and fixed by Zulux91 in PS3Native.