Skip to content

Multiple race conditions when saving files #1539

@p-e-w

Description

@p-e-w

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 with Buffer.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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions