dyng / dyng/ctrlsf.vim

"free(): invalid pointer" when doing async searches with neovim

Open
#326 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Vim Script
Stars
1.6k
Forks
89
PR merge metrics
No merged PRs in 30d

Description

#### Issue description

Its not always, but I noticed that when you try doing a search that will result in a lot of entries, it first displays a weird error (its gigantic, so I will paste it below), and then it starts the async search, and whenever I switch to the search buffer, my normal buffer gets replaced with the same contents as the search buffer (minus highlighting, image showing this below), and whenever I try to close any of the buffers (by doing `:bd` or `:q`), neovim crashes and the following message appears on the console:

the neovim crash
```zsh
free(): invalid pointer
zsh: abort (core dumped) nvim
%
```

the buffer being replaced with a copy of the search buffer (it updates whenever the search buffer updates as well):
image

the gigantic first error:
```bash
line 2:
E315: ml_get: invalid lnum: 319
Error detected while processing function ctrlsf#async#ParseAndDrawCB[7]..ctrlsf#win#DrawIncr[11]..ctrlsf#buf#SetLine[4]..99_setbufline:
line 2:
E315: ml_get: invalid lnum: 319
Error detected while processing function ctrlsf#async#ParseAndDrawCB[7]..ctrlsf#win#DrawIncr[11]..ctrlsf#buf#SetLine[4]..99_setbufline:
line 2:
E315: ml_get: invalid lnum: 318
Error detected while processing function ctrlsf#async#NeoVimSearchCBWrapper:
line 7:
E16: Invalid range: call remove(a:data, -1)
Error detected while processing function ctrlsf#async#NeoVimSearchCBWrapper:
line 7:
E16: Invalid range: call remove(a:data, -1)
Error detected while processing function ctrlsf#async#NeoVimSearchCBWrapper:
line 7:
E16: Invalid range: call remove(a:data, -1)
Error detected while processing function 81_illuminate:
line 5:
E16: Invalid range: call s:remove_illumination()
Error detected while processing function ctrlsf#async#ParseAndDrawCB:
line 2:
E16: Invalid range: call ctrlsf#log#Debug("ConsumeResult: size=%s", len(lines))
Error detected while processing function ctrlsf#async#NeoVimSearchCBWrapper:
line 2:
E16: Invalid range: call ctrlsf#async#SearchCloseCB('unused')
E315: ml_get: invalid lnum: 285
E315: ml_get: invalid lnum: 286
E315: ml_get: invalid lnum: 287
E315: ml_get: invalid lnum: 288
E315: ml_get: invalid lnum: 289
E315: ml_get: invalid lnum: 290
E315: ml_get: invalid lnum: 291
E315: ml_get: invalid lnum: 292
E315: ml_get: invalid lnum: 293
E315: ml_get: invalid lnum: 294
E315: ml_get: invalid lnum: 295
E315: ml_get: invalid lnum: 296
E315: ml_get: invalid lnum: 297
E315: ml_get: invalid lnum: 298
E315: ml_get: invalid lnum: 299
E315: ml_get: invalid lnum: 300
E315: ml_get: invalid lnum: 301
E315: ml_get: invalid lnum: 302
E315: ml_get: invalid lnum: 303
E315: ml_get: invalid lnum: 304
E315: ml_get: invalid lnum: 305
E315: ml_get: invalid lnum: 306
E315: ml_get: invalid lnum: 307
E315: ml_get: invalid lnum: 308
E315: ml_get: invalid lnum: 309
E315: ml_get: invalid lnum: 310
E315: ml_get: invalid lnum: 311
E315: ml_get: invalid lnum: 312
E315: ml_get: invalid lnum: 313
E315: ml_get: invalid lnum: 314
E315: ml_get: invalid lnum: 315
E315: ml_get: invalid lnum: 316
E315: ml_get: invalid lnum: 317
E315: ml_get: invalid lnum: 318
E315: ml_get: invalid lnum: 319
E315: ml_get: invalid lnum: 285
E315: ml_get: invalid lnum: 286
E315: ml_get: invalid lnum: 287
E315: ml_get: invalid lnum: 288
E315: ml_get: invalid lnum: 289
E315: ml_get: invalid lnum: 290
E315: ml_get: invalid lnum: 291
E315: ml_get: invalid lnum: 292
E315: ml_get: invalid lnum: 293
E315: ml_get: invalid lnum: 294
E315: ml_get: invalid lnum: 295
E315: ml_get: invalid lnum: 296
E315: ml_get: invalid lnum: 297
E315: ml_get: invalid lnum: 298
E315: ml_get: invalid lnum: 299
E315: ml_get: invalid lnum: 300
E315: ml_get: invalid lnum: 301
E315: ml_get: invalid lnum: 302
E315: ml_get: invalid lnum: 303
E315: ml_get: invalid lnum: 304
E315: ml_get: invalid lnum: 305
E315: ml_get: invalid lnum: 306
E315: ml_get: invalid lnum: 307
E315: ml_get: invalid lnum: 308
E315: ml_get: invalid lnum: 309
E315: ml_get: invalid lnum: 310
E315: ml_get: invalid lnum: 311
E315: ml_get: invalid lnum: 312
E315: ml_get: invalid lnum: 313
E315: ml_get: invalid lnum: 314
E315: ml_get: invalid lnum: 315
E315: ml_get: invalid lnum: 316
E315: ml_get: invalid lnum: 317
E315: ml_get: invalid lnum: 318
E315: ml_get: invalid lnum: 319
```

#### Things about your system and environment

| field | value |
|:-------:|:------------------------------------:|
| os | *OS X Monterey 12.2.1* |
| vim | *NVIM v0.7.0* |
| backend | *ripgrep 13.0.0* |
| locale | *en_US.UTF-8* |

- log:

Its difficult to post the log, as there's a lot of private code as well in there... If there's anything in specific, I can try to search for it

- vimrc:

```vim
let g:ctrlsf_ackprg = 'rg'

let g:ctrlsf_auto_focus = {
\ "at": "done",
\ "duration_less_than": 1000
\ }

let g:ctrlsf_mapping = {
\ "next": "n",
\ "prev": "N",
\ "quit": "gq",
\ }

let g:ctrlsf_extra_backend_args = {
\ 'rg': '--hidden --glob "!.git/*"'
\ }
let g:ctrlsf_populate_qflist = 1

nnoremap f :CtrlSF
nnoremap f :CtrlSF
vmap f CtrlSFVwordPath
command! CSFT execute ":CtrlSFToggle"
```

- file:

Theres nothing in specific on any file, its random, I can make the same search twice, and first it breaks, and then it works fine... I noticed it usually happen on async searches, with lots of results being displayed

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.