plans: chat console race: crash window

This commit is contained in:
Narasimha-sc committed 2026-10-19 19:30:02 +00:00
1 parent d115d9c6a1
commit b67d102c1e
1 file changed
+1 -1
+1 -1
View File
@@ -7,7 +7,7 @@ Issue #7755.
`ChatModel.addTerminalItem(item, maxItems)` reads `terminalItems.value` for the size check, twice on the `subList` line (the list and its size), and again for the append, without a lock. While no chat console is open, it runs on the caller's thread: `sendCmd` on the IO dispatcher, the receiver loop, and the migration receivers, several at once. (With a console open, writes are posted to the main thread.)
Two concurrent calls can:
- crash with `IndexOutOfBoundsException: toIndex = 201` in `subList`: another thread appended between the two reads of `terminalItems.value` in the `subList` line (that thread had skipped the trim on an out-of-date size check, so the list went past the cap);
- crash with `IndexOutOfBoundsException: toIndex = 201` in `subList`: another thread appended between the two reads of `terminalItems.value` in the `subList` line;
- lose a row: both read the same list and the second write replaces the first;
- keep the list above the cap.