cogentcore / core

A free and open source framework for building powerful, fast, and elegant 2D and 3D apps that run on macOS, Windows, Linux, iOS, Android, and the Web with a single pure Go codebase, allowing you to Code Once, Run Everywhere.
http://cogentcore.org/core
BSD 3-Clause "New" or "Revised" License
1.31k stars 71 forks source link

eventmgr HandleLong can hang in lock deadlock #895

Closed rcoreilly closed 4 months ago

rcoreilly commented 4 months ago

Describe the bug

In a std event thread, it is deadlocked trying to get em.TimeMu.Lock, while the timer AfterFunc is deadlocked trying to get rc.Lock for sending the event outside of the normal event function. Can't hold both of these locks at the same time! not 100% clear why we need TimerMu lock inside the afterfunc when it is't doing anything in relation to the timer?

How to reproduce

semi-hard to reproduce -- fiddling with the splits seems to work in core eventually.

Example code

No response

Relevant output

No response

Platform

macOS

rcoreilly commented 4 months ago

actually, changing the order of the two locks in the afterfunc should, and appears to, fix the issue: once you get the overall rendercontext lock, then you know nobody else can be trying to get the delay lock..