Repository: neovim
Issue: crash in marktree_splice from set_buffer_lines
Labels: needs:repro,has:backtrace,bug-crash,marks

<!-- Before reporting: search existing issues and check the FAQ. -->

- `nvim --version`: https://github.com/neovim/neovim/commit/7c204af87aa74120a70db14b87c5e7c7096ae478
- Operating system/version: nixos
- Terminal name/version: kitty

Tried to reproduce but couldn't (yet), Happened while editing (a one line file, 3/4 words).
```
#0  0x00007f3888c2033a in raise () from /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libc.so.6
[Current thread is 1 (Thread 0x7f3888bc5740 (LWP 28813))]
(ins)(gdb) bt
#0  0x00007f3888c2033a in raise () from /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libc.so.6
#1  0x00007f3888c0a523 in abort () from /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libc.so.6
#2  0x00007f3888c0a41f in __assert_fail_base.cold.0 () from /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libc.so.6
Reading in symbols for /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/marktree.c...
#3  0x00007f3888c18d92 in __assert_fail () from /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libc.so.6
#4  0x000000000054df2a in relative (base=..., Reading in symbols for /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/extmark.c...
val=0x178e580) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/marktree.c:76
#5  0x000000000054f2c7 in marktree_splice (b=0x1800000000, b@entry=0x154aef8, start_line=start_line@entry=0, start_col=start_col@entry=0, old_extent_line=old_extent_line@entry=0, old_extent_col=<optimized out>, old_extent_col@entry=22, 
    new_extent_line=<optimized out>, new_extent_line@entry=0, new_extent_col=24) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/marktree.c:987
#6  0x000000000050bed0 in extmark_splice_impl (buf=buf@entry=0x1548010, start_row=start_row@entry=0, start_col=0, start_byte=<optimized out>, old_row=old_row@entry=0, old_col=old_col@entry=22, old_byte=<optimized out>, new_row=<optimized out>, 
    new_col=<optimized out>, new_byte=<optimized out>, undo=<optimized out>) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/extmark.c:626
#7  0x000000000050c460 in extmark_splice (Reading in symbols for /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/change.c...
Reading in symbols for /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/eval.c...
buf=0x1548010, start_row=start_row@entry=0, start_col=start_col@entry=0, old_row=old_row@entry=0, old_col=22, old_byte=22, new_row=<optimized out>, new_col=<optimized out>, new_byte=<optimized out>, undo=<optimized out>)
    at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/extmark.c:598
#8  0x000000000050c48d in extmark_splice_cols (buf=0x2, start_row=23057376, start_row@entry=0, start_col=start_col@entry=0, old_col=<optimized out>, new_col=<optimized out>, undo=8, undo@entry=kExtmarkUndo)
    at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/extmark.c:693
#9  0x0000000000481673 in inserted_bytes (Reading in symbols for /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/eval/funcs.c...
lnum=lnum@entry=1, col=col@entry=0, old=-2000551110, new=0) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/change.c:368
#10 0x00000000004a8928 in set_buffer_lines (Reading in symbols for /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/eval/userfunc.c...
buf=0x1548010, lnum_arg=<optimized out>, append=false, lines=lines@entry=0x7ffc015fddc0, rettv=rettv@entry=0x7ffc015fdfa0) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/eval.c:7062
#11 0x00000000004bcb5a in f_setline (argvars=0x7ffc015fddb0, rettv=0x0, fptr=<optimized out>) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/eval/funcs.c:8272
#12 0x00000000004d2312 in call_func (funcname=0x1796850 "setline", funcname@entry=0x1 <error: Cannot access memory at address 0x1>, len=7, len@entry=32764, rettv=0x7ffc015fdfa0, rettv@entry=0x1, argcount_in=argcount_in@entry=2, 
    argvars_in=<optimized out>, argvars_in@entry=0x7ffc015fdd80, argv_func=argv_func@entry=0x0, firstline=1, lastline=1, doesrange=0x7ffc015fdf9c, evaluate=<optimized out>, partial=0x0, selfdict_in=0x0)
    at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/eval/userfunc.c:1578
#13 0x00000000004d1f4b in get_func_tv (Reading in symbols for /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/ex_docmd.c...
name=<optimized out>, name@entry=0x0, len=<optimized out>, len@entry=-1, rettv=<optimized out>, rettv@entry=0x7ffc015fdfa0, arg=<optimized out>, arg@entry=0x7ffc015fdfb8, firstline=<optimized out>, lastline=<optimized out>, doesrange=<optimized out>, 
    evaluate=<optimized out>, partial=<optimized out>, selfdict=<optimized out>) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/eval/userfunc.c:470
#14 0x00000000004d66cc in ex_call (eap=0x7ffc015fe020) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/eval/userfunc.c:2963
#15 0x00000000004ee867 in do_one_cmd (cmdlinep=cmdlinep@entry=0x7ffc015fe2e0, flags=flags@entry=7, cstack=cstack@entry=0x7ffc015fe2e8, fgetline=fgetline@entry=0x4ed6f0 <get_loop_line>, cookie=<optimized out>, cookie@entry=0x7ffc015fe268)
    at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/ex_docmd.c:1969
#16 0x00000000004ecad6 in do_cmdline (cmdline=<optimized out>, cmdline@entry=0x0, fgetline=0x4d32d0 <get_func_line>, cookie=<optimized out>, cookie@entry=0x178fab0, flags=flags@entry=7)
    at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/ex_docmd.c:598
#17 0x00000000004d2e83 in call_user_func (fp=<optimized out>, fp@entry=0x1134080, argcount=0, argvars=<optimized out>, argvars@entry=0x7ffc015fee60, rettv=rettv@entry=0x7ffc015fee30, firstline=<optimized out>, lastline=<optimized out>, selfdict=0x0)
    at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/eval/userfunc.c:1121
#18 0x00000000004d24aa in call_func (funcname=funcname@entry=0x13e9fa0 "<SNR>130_go", len=<optimized out>, rettv=rettv@entry=0x7ffc015fee30, argcount_in=argcount_in@entry=1, argvars_in=<optimized out>, argvars_in@entry=0x7ffc015fee60, 
    argv_func=argv_func@entry=0x0, firstline=1, lastline=1, doesrange=0x7ffc015fedec, evaluate=<optimized out>, partial=0x0, selfdict_in=0x0) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/eval/userfunc.c:1563
#19 0x00000000004a1f58 in call_vim_function (Reading in symbols for /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/normal.c...
func=0x13e9fa0 "<SNR>130_go", argc=argc@entry=1, argv=argv@entry=0x7ffc015fee60, rettv=rettv@entry=0x7ffc015fee30) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/eval.c:1053
#20 0x00000000004a1ffd in call_func_retnr (func=0x2 <error: Cannot access memory at address 0x2>, argc=23057376, argc@entry=1, argv=0x0, argv@entry=0x7ffc015fee60) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/eval.c:1078
#21 0x000000000056fabc in op_function (oap=oap@entry=0x7ffc015fefd8) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/normal.c:2152
#22 0x000000000056f156 in do_pending_operator (cap=<optimized out>, cap@entry=0x7ffc015ff048, old_col=0, gui_yank=<optimized out>) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/normal.c:1958
#23 0x000000000057a83b in normal_finish_command (Reading in symbols for /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/state.c...
s=s@entry=0x7ffc015fefc0) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/normal.c:884
#24 0x00000000005734af in normal_execute (state=0x7ffc015fefc0, key=<optimized out>) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/normal.c:1145
#25 0x00000000006045a4 in state_enter (Reading in symbols for /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/main.c...
s=s@entry=0x7ffc015fefc0) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/state.c:69
#26 0x000000000056e328 in normal_enter (cmdwin=<optimized out>, noexmode=<optimized out>) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/normal.c:463
#27 0x0000000000540086 in main (argc=<optimized out>, argv=<optimized out>) at /build/m8ddvdgqbip5fjsa5nvr87xhg6xmm9rc-source/src/nvim/main.c:562
### Steps to reproduce using `nvim -u NORC`
```

### Actual behaviour

### Expected behaviour