Commit 2a5a2aa
fix: prevent data race between Terminal.Write and Terminal.State
Terminal.Write (via WriteSync/Parse/setChar) modified the terminal's
cell buffer while Terminal.State (via tty.Capture/image.Capture) read
it concurrently without synchronization.
Fix by holding the struct-level RWMutex in both Write (exclusive) and
State (shared read). To avoid deadlocking with Resize—which previously
held the lock during the blocking stream.Resize call—release the lock
in Resize before performing stream I/O.
Co-Authored-By: Claude Opus 4.6 <[email protected]>1 parent b1ab8db commit 2a5a2aa
1 file changed
+2
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
100 | 99 | | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
| |||
0 commit comments