Skip to content

bug: strategy/system.lua crashes with "Invalid buffer id" in vim.schedule callbacks #508

@yaadata

Description

@yaadata

Neovim version: 0.11.6

Operating system/version: macOS 26.3.1

Describe the bug:

The system strategy crashes with "Invalid buffer id" errors when a task's output buffer is closed/wiped while the task is still running or finishing. Two vim.schedule callbacks in strategy/system.lua access self.bufnr without checking buffer validity:

  • Line 115on_output calls vim.api.nvim_buf_line_count(self.bufnr)
  • Line 213 — exit handler sets vim.bo[self.bufnr].modifiable = true

PR #415 (commit 100e969) fixed similar issues in util.lua but these call sites were not covered.

Error executing vim.schedule lua callback: .../overseer/strategy/system.lua:115: Invalid buffer id: 2
stack traceback:
    [C]: in function 'nvim_buf_line_count'
    .../overseer/strategy/system.lua:115: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>

Error executing vim.schedule lua callback: .../overseer/strategy/system.lua:213: Invalid buffer id: 3
stack traceback:
    [C]: in function '__newindex'
    .../overseer/strategy/system.lua:213: in function <.../overseer/strategy/system.lua:209>

Severity: tolerable (can work around it)

Steps To Reproduce:

  1. Run a task using the system strategy
  2. Close/wipe the task output buffer while the task is still running or finishing
  3. Errors appear as the vim.schedule callbacks fire on the now-invalid buffer

Expected Behavior:

Callbacks should check vim.api.nvim_buf_is_valid(self.bufnr) and return early if the buffer has been wiped, similar to the guards added in #415.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions