-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Description of the problem or steps to reproduce
As far as I can tell, there is currently no locking at all when saving/loading files. This sets the stage for several potentially dangerous race conditions:
-
If a plugin calls
Buffer.Save()from an separate goroutine (e.g. a timer or a background job), this save might interleave with a user-initiated save operation, corrupting the file. -
Buffer.ReOpen()can also interleave withBuffer.Save(), loading the file in a partially written state. -
Buffer.Backup()is called asynchronously every 8 seconds (while the buffer is being modified). This means that if creating the backup takes longer than 8 seconds (e.g. slow network mount), the writes will also interleave and potentially corrupt the backup.
There might be more, this is just what I noticed from a quick look through the code.
Specifications
Commit hash: 2ef4f83
OS: Fedora 31
Terminal: GNOME Terminal