Mayil-AI-Sandbox / neovim_29484

Sandbox repository
Other
0 stars 0 forks source link

Crash when adding extmark in decor provider #1

Open NobleMathews opened 5 days ago

NobleMathews commented 5 days ago

Problem

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib                 0x183932a60 __pthread_kill + 8
1   libsystem_pthread.dylib                0x18396ac20 pthread_kill + 288
2   libsystem_c.dylib                      0x183877a20 abort + 180
3   libsystem_c.dylib                      0x183876d10 __assert_rtn + 284
4   nvim                                   0x104a83474 marktree_itr_next_skip.cold.1 + 40 (marktree.c:1558)
5   nvim                                   0x10485eac8 marktree_itr_next_skip + 584 (marktree.c:1558)
6   nvim                                   0x10475fe8c decor_redraw_col + 180 (decoration.c:614)
7   nvim                                   0x10476b87c win_line + 9020 (drawline.c:1667)
8   nvim                                   0x104772ecc win_update + 4924 (drawscreen.c:2302)
9   nvim                                   0x104771808 update_screen + 3256 (drawscreen.c:648)
10  nvim                                   0x10489c040 normal_redraw + 44 (normal.c:1354) [inlined]
11  nvim                                   0x10489c040 normal_check + 968 (normal.c:1456)
12  nvim                                   0x10493f474 state_enter + 100 (state.c:40)
13  nvim                                   0x10488f420 normal_enter + 160 (normal.c:519)
14  nvim                                   0x10484d8ac main + 9484 (main.c:664)
15  dyld                                   0x1835e20e0 start + 2360

Assert is firing:

      assert(itr->x->ptr[itr->i]->parent == itr->x);

Steps to reproduce

min.lua:

vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
vim.wo.foldmethod = 'expr'
vim.o.swapfile = false

vim.api.nvim_create_autocmd('FileType', {
  pattern = { 'c' },
  callback = function(args)
    vim.treesitter.start(args.buf)
    vim.lsp.start({
      cmd = { 'clangd' },
      root_dir = vim.fs.root(args.buf, {'.git'})
    })
  end,
})

local ns = vim.api.nvim_create_namespace('foldsize')
vim.api.nvim_set_decoration_provider(ns, {
  on_line = function(_, _winid, bufnr, row)
    vim.api.nvim_buf_clear_namespace(bufnr, ns, row, row+1)
    vim.api.nvim_buf_set_extmark(bufnr, ns, row, 0, {
      virt_text_pos = 'right_align',
      virt_text = { { 'TEXT', 'Folded' } },
    })
  end
})
  1. Checkout nvim codebase
  2. Install clangd
  3. nvim --clean -u min.lua src/nvim/move.c
  4. make window width ~20 cells
  5. Gx

If that doesn't work, scroll, edit, close open folds. Eventually assert will trigger.

Neovim version (nvim -v)

NVIM v0.11.0-dev-312

Operating system/version

macOS 14.4.1

Terminal name/version

ghostty

$TERM environment variable

xterm-ghostty

Installation

Source

mayil-ai[bot] commented 5 days ago

Here are some code snippets that may help you get started:

To address the issue with the extmark crash, follow these actionable steps:

By implementing these steps, you can address the inconsistency in the MarkTree structure and prevent the assertion failure.

💡 To rerun Mayil, comment mayil-ai rerun. Mayil will incorporate any new context added to the ticket. Include details in your rerun comment to guide Mayil!