liamg / darktile

:waning_crescent_moon: Darktile is a GPU rendered terminal emulator designed for tiling window managers.
MIT License
3.03k stars 113 forks source link

Fix terminal state and key state data races #335

Closed ernestrc closed 2 years ago

ernestrc commented 2 years ago

I am using darktile for an internal project and stumbled upon a few data races. In essence, we are processing input via io.Copy->Terminal.Write->handleInput concurrently without synchronizing with the main rendering loop (GUI.Update->...->g.terminal.GetActiveBuffer).

I haven't done any analysis on contention but at first glance we might be adding some, since we are blocking on internal calls to WriteToPty etc. This solution was enough for my purposes so feel free to close PR if you think a more sophisticated approach is required.