Repository: neovim
Issue: SIGSEGV on second call to :checkhealth for a missing plugin with nui/noice
Labels: has:repro,has:backtrace,bug-crash,floatwin

### Neovim version (nvim -v)

`NVIM v0.9.0-dev` it's nightly from nix so, maybe 090048bec9f80c46a6ce6ff05a419b15bc4bf028 but hard to tell without pr #21210 

### Vim (not Nvim) behaves the same?

no, needs lua

### Operating system/version

macOS 12.6.1

### Terminal name/version

iTerm2 Build 3.5.0beta7

### $TERM environment variable

xterm-256color

### Installation

nix nightly flake

### How to reproduce the issue

I couldn’t figure out how to get all the lua requires to work with `nvim --clean` sorry. I got as far as `:lua package.path = package.path .. ";/tmp/noice.nvim/lua/?/init.lua;/tmp/nui/lua/?/init.lua"` but can't figure out how to get noice to actually require under `--clean`

Using `nvim -u NONE` and these versions, installed from packer

```
noice e013b6ebbad0fab34013be6f073da38c53c9e1dc
nui 2a6533fb798efad7dd783311315bab8dc5eb381b
```

Then run the same missing health check twice:

```
:lua require('noice').setup()
:checkhealth a
:checkhealth a
```

 

### Expected behavior

```
==============================================================================
a: 

- ERROR No healthcheck found for "a" plugin.
```

both times

### Actual behavior

The first time you get `ERROR No healthcheck found for "a" plugin.` but the second time you get a segfault


```
      fish: Job 1, 'nvim' terminated by signal SIGSEGV (Address boundary error)
```

I grabbed a backtrace:

```gdb

Target 0: (nvim) stopped.
Executable module set to "/nix/store/2s1dg536zxi2k794sxxp63qn52mc8s7k-neovim-unwrapped-master/bin/nvim".
Architecture set to: arm64e-apple-macosx-.
(lldb) c
Process 71030 resuming
Process 71030 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x38)
    frame #0: 0x0000000102b9b320 nvim`winframe_remove + 92
nvim`winframe_remove:
->  0x102b9b320 <+92>:  ldr    x8, [x0, #0x38]
    0x102b9b324 <+96>:  mov    x19, x8
    0x102b9b328 <+100>: cbnz   x8, 0x102b9b33c           ; <+120>
    0x102b9b32c <+104>: mov    x9, x20
Target 0: (nvim) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x38)
  * frame #0: 0x0000000102b9b320 nvim`winframe_remove + 92
    frame #1: 0x0000000102ba06e0 nvim`win_free_mem + 160
    frame #2: 0x0000000102b9ff88 nvim`win_close_othertab + 628
    frame #3: 0x0000000102b9fce4 nvim`close_windows + 404
    frame #4: 0x00000001029601e0 nvim`do_buffer + 880
    frame #5: 0x000000010296109c nvim`do_bufdel + 340
    frame #6: 0x00000001029ecbbc nvim`ex_bunload + 64
    frame #7: 0x00000001029e88d0 nvim`execute_cmd0 + 256
    frame #8: 0x00000001029e48f0 nvim`do_cmdline + 8516
    frame #9: 0x00000001029cb224 nvim`call_user_func + 1940
    frame #10: 0x00000001029caa44 nvim`call_func + 2096
    frame #11: 0x00000001029ca188 nvim`get_func_tv + 608
    frame #12: 0x00000001029cf5fc nvim`ex_call + 716
    frame #13: 0x00000001029e88d0 nvim`execute_cmd0 + 256
    frame #14: 0x00000001029e48f0 nvim`do_cmdline + 8516
    frame #15: 0x00000001029a530c nvim`ex_checkhealth + 96
    frame #16: 0x00000001029e88d0 nvim`execute_cmd0 + 256
    frame #17: 0x00000001029e48f0 nvim`do_cmdline + 8516
    frame #18: 0x0000000102a9912c nvim`nv_colon + 240
    frame #19: 0x0000000102a96964 nvim`normal_execute + 5940
    frame #20: 0x0000000102b51ecc nvim`state_enter + 140
    frame #21: 0x0000000102a92c10 nvim`normal_enter + 140
    frame #22: 0x0000000102a508f4 nvim`main + 8996
    frame #23: 0x0000000102f8508c dyld`start + 520
(lldb)
```