Fix highlighting crash when line index is outdated - #4146
Conversation
|
I just got this as well and lost (unsaved) data (although nothing too important) because of this. Maybe we should merge this since it is a crash, not to mention plugins can call this directly with out of bound Loc and crash it as well. |
|
I saw this PR already, but had the same feeling as @omarelladen with...
...that it will cover/hide the real root cause of asynchronous access or insufficient access order. |
|
Just to make sure I am on the same page, correct me if I am wrong, the crash is in micro/internal/display/bufwindow.go Line 383 in 77de728 which is called from Line 504 in 22930a5
What is running asynchronously/concurrently when Otherwise, somehow |
A couple of things are running concurrently with it (e.g. syntax highlighter, background backups) but none of them are supposed to modify the buffer. It is only supposed to be modified by the main goroutine. |
|
I took a look at all the places that have I agree the current fix will cover/obfuscate the issue, but at the same time I feel like we should be doing something better than straight up crashing atm. Unless someone can have another go to see see if there's anything obvious that I missed (which is like not unlikely, golang is not my main lang afterall) If not, maybe we can:
How does this sound? [Edit]: Ideally I do want to merge this... at some point since plugins can call this function and crash micro by passing an invalid arg. |
|
@Neko-Box-Coder
The
It was off by 9. |
A random crash happened to me:
Since I was using version 2.0.14-1+b6 from Debian, the problem is in this line:
micro/internal/buffer/line_array.go
Line 389 in 77de728
(check https://sources.debian.org/src/micro/2.0.14-1/internal/buffer/line_array.go#L394)
I could not reproduce the bug, but it seems to me that the highlighter was trying to access a line that was just deleted, using an outdated Y position of the window. So this proposed fix is simple, but the concurrent access problem can be deeper.