Repository: neovim
Issue: SegFault in frame_new_height() when trying to close `diffview` window
Labels: ui,needs:repro,has:backtrace,bug-crash

### Describe the bug

This screenshot seems to be the most valuable information I have.

![Screenshot](https://i.redd.it/l7ld9ox8uyga1.png)

I was not sure about what to do so I made [a Reddit post](https://www.reddit.com/r/neovim/comments/10wwkft/met_a_segfault_on_neovim_anyone_has_any_ideas/) before I decided to report it here. Some people have given some thoughts there.

Crash report from `Console.app`

```log
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               nvim [10402]
Path:                  /opt/homebrew/*/nvim
Identifier:            nvim
Version:               ???
Code Type:             ARM-64 (Native)
Parent Process:        fish [9764]
Responsible:           alacritty [795]
User ID:               501

Date/Time:             2023-02-07 18:25:11.3976 +0800
OS Version:            macOS 12.6 (21G115)
Report Version:        12
Anonymous UUID:        084EC63E-4105-DEF1-67EC-007D6754BFBA

Sleep/Wake UUID:       341B68BD-0AA9-4463-8464-0585AA6D5C35

Time Awake Since Boot: 1000000 seconds
Time Since Wake:       1070 seconds

System Integrity Protection: disabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000018
Exception Codes:       0x0000000000000001, 0x0000000000000018
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [10402]

VM Region Info: 0x18 is not in any region.  Bytes before following region: 105553518919656
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-/rwx SM=NUL  ...(unallocated)

Kernel Triage:
VM - pmap_enter failed with resource shortage
VM - pmap_enter failed with resource shortage


Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   nvim                          	       0x1031969b0 frame_new_height + 44
1   nvim                          	       0x103194090 winframe_remove + 596
2   nvim                          	       0x103194090 winframe_remove + 596
3   nvim                          	       0x103198bb8 win_free_mem + 128
4   nvim                          	       0x10319284c win_close + 1824
5   nvim                          	       0x102f853cc nvim_win_close + 332
6   nvim                          	       0x102f5b574 nlua_api_nvim_win_close + 380
7   libluajit-5.1.2.1.0.dylib     	       0x10367bed4 0x103678000 + 16084
8   libluajit-5.1.2.1.0.dylib     	       0x1036889fc lua_pcall + 148
9   nvim                          	       0x1030707a0 nlua_call_ref + 216
10  nvim                          	       0x102f8c004 getnextac + 1188
11  nvim                          	       0x103013878 do_cmdline + 2012
12  nvim                          	       0x102f8a988 apply_autocmds_group + 1812
13  nvim                          	       0x103198a50 do_autocmd_winclosed + 136
14  nvim                          	       0x103192304 win_close + 472
15  nvim                          	       0x102f8f264 do_buffer + 1444
16  nvim                          	       0x102f8ff60 do_bufdel + 212
17  nvim                          	       0x10301d21c ex_bunload + 64
18  nvim                          	       0x10301925c execute_cmd0 + 244
19  nvim                          	       0x103016084 do_cmdline + 12264
20  nvim                          	       0x1030b9e38 nv_colon + 416
21  nvim                          	       0x1030b7860 normal_execute + 4172
22  nvim                          	       0x10314ea74 state_enter + 360
23  nvim                          	       0x10307b6a4 main + 10716
24  dyld                          	       0x10344908c start + 520

Thread 1:
0   libsystem_kernel.dylib        	       0x19e414c20 kevent + 8
1   libuv.1.dylib                 	       0x103541e04 uv__io_poll + 760
2   libuv.1.dylib                 	       0x1035327d0 uv_run + 252
3   nvim                          	       0x103004ddc loop_uv_run + 136
4   nvim                          	       0x1031726e8 tui_main + 708
5   libsystem_pthread.dylib       	       0x19e44c26c _pthread_start + 148
6   libsystem_pthread.dylib       	       0x19e44708c thread_start + 8

Thread 2:
0   libsystem_kernel.dylib        	       0x19e412270 __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x19e44c83c _pthread_cond_wait + 1236
2   libuv.1.dylib                 	       0x10353d758 uv_cond_wait + 12
3   libuv.1.dylib                 	       0x10352f3c0 worker + 344
4   libsystem_pthread.dylib       	       0x19e44c26c _pthread_start + 148
5   libsystem_pthread.dylib       	       0x19e44708c thread_start + 8

Thread 3:
0   libsystem_kernel.dylib        	       0x19e412270 __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x19e44c83c _pthread_cond_wait + 1236
2   libuv.1.dylib                 	       0x10353d758 uv_cond_wait + 12
3   libuv.1.dylib                 	       0x10352f3c0 worker + 344
4   libsystem_pthread.dylib       	       0x19e44c26c _pthread_start + 148
5   libsystem_pthread.dylib       	       0x19e44708c thread_start + 8

Thread 4:
0   libsystem_kernel.dylib        	       0x19e412270 __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x19e44c83c _pthread_cond_wait + 1236
2   libuv.1.dylib                 	       0x10353d758 uv_cond_wait + 12
3   libuv.1.dylib                 	       0x10352f3c0 worker + 344
4   libsystem_pthread.dylib       	       0x19e44c26c _pthread_start + 148
5   libsystem_pthread.dylib       	       0x19e44708c thread_start + 8

Thread 5:
0   libsystem_kernel.dylib        	       0x19e412270 __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x19e44c83c _pthread_cond_wait + 1236
2   libuv.1.dylib                 	       0x10353d758 uv_cond_wait + 12
3   libuv.1.dylib                 	       0x10352f3c0 worker + 344
4   libsystem_pthread.dylib       	       0x19e44c26c _pthread_start + 148
5   libsystem_pthread.dylib       	       0x19e44708c thread_start + 8

Thread 6:
0   libsystem_pthread.dylib       	       0x19e447078 start_wqthread + 0


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x000000012c967a00   x1: 0x000000006e69206f   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x00000000fffffffd   x5: 0x000000012c867000   x6: 0x0000000000000000   x7: 0x0000000000000000
    x8: 0x0000000000000000   x9: 0x000000000000000a  x10: 0x0000000000000000  x11: 0x0000000000000000
   x12: 0x0000000000000001  x13: 0x0000000000000000  x14: 0x0000000047600000  x15: 0x0000000000006be4
   x16: 0x000000019e4630d0  x17: 0x00000000000008fd  x18: 0x0000000000000000  x19: 0x0000600001f55600
   x20: 0x000000006e69206f  x21: 0x000000012c9ac400  x22: 0x000000016ceb8860  x23: 0x0000000103244a48
   x24: 0x0000600001f55100  x25: 0x0000000000000000  x26: 0x0000600001f54e80  x27: 0x000000012c9aeb41
   x28: 0x0000000103244a50   fp: 0x000000016ceb8790   lr: 0x0000000103194090
    sp: 0x000000016ceb8750   pc: 0x00000001031969b0 cpsr: 0x20001000
   far: 0x0000000000000018  esr: 0x92000006 (Data Abort) byte read Translation fault

Binary Images:
       0x102f44000 -        0x103217fff nvim (*) <8df66dbc-78fe-3f17-a934-78e56f9e75a4> /opt/homebrew/*/nvim
       0x103678000 -        0x1036e7fff libluajit-5.1.2.1.0.dylib (*) <7752e7ee-61de-3529-8abf-05250860a287> /opt/homebrew/*/libluajit-5.1.2.1.0.dylib
       0x103444000 -        0x1034a3fff dyld (*) <38ee9fe9-b66d-3066-8c5c-6ddf0d6944c6> /usr/lib/dyld
       0x19e40d000 -        0x19e444fff libsystem_kernel.dylib (*) <a9d87740-9c1d-3468-bf60-720a8d713cba> /usr/lib/system/libsystem_kernel.dylib
       0x10352c000 -        0x103547fff libuv.1.dylib (*) <870e1cf7-0a62-382a-b74b-c1e970aa3db2> /opt/homebrew/*/libuv.1.dylib
       0x19e445000 -        0x19e451fff libsystem_pthread.dylib (*) <63c4eef9-69a5-38b1-996e-8d31b66a051d> /usr/lib/system/libsystem_pthread.dylib
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 20
    thread_create: 3
    thread_set_state: 333

VM Region Summary:
ReadOnly portion of Libraries: Total=742.0M resident=0K(0%) swapped_out_or_unallocated=742.0M(100%)
Writable regions: Total=1.7G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.7G(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                   256K        1 
Kernel Alloc Once                   32K        1 
MALLOC                           267.2M       36 
MALLOC guard page                   96K        4 
MALLOC_MEDIUM (reserved)         960.0M        8         reserved VM address space (unallocated)
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
STACK GUARD                       56.1M        7 
Stack                             48.6M        7 
VM_ALLOCATE                       55.2M      442 
__AUTH                            1586K      104 
__AUTH_CONST                      7051K      227 
__DATA                            7361K      226 
__DATA_CONST                      7935K      243 
__DATA_DIRTY                       328K       81 
__FONT_DATA                          4K        1 
__LINKEDIT                       578.5M       20 
__OBJC_CONST                       713K       81 
__OBJC_RO                         83.0M        1 
__OBJC_RW                         3168K        1 
__TEXT                           163.5M      255 
__UNICODE                          592K        1 
dyld private memory               1024K        1 
mapped file                       29.1M        3 
shared memory                       64K        4 
===========                     =======  ======= 
TOTAL                              2.6G     1756 
TOTAL, minus reserved VM space     1.3G     1756 



-----------
Full Report
-----------

{"app_name":"nvim","timestamp":"2023-02-07 18:25:12.00 +0800","app_version":"","slice_uuid":"8df66dbc-78fe-3f17-a934-78e56f9e75a4","build_version":"","platform":1,"share_with_app_devs":0,"is_first_party":1,"bug_type":"309","os_version":"macOS 12.6 (21G115)","incident_id":"F261A133-E7F3-430E-AAF1-52A2B35A64E6","name":"nvim"}
{
  "uptime" : 1000000,
  "procLaunch" : "2023-02-07 14:28:10.8342 +0800",
  "procRole" : "Unspecified",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "MacBookPro17,1",
  "procStartAbsTime" : 23866535296046,
  "coalitionID" : 826,
  "osVersion" : {
    "train" : "macOS 12.6",
    "build" : "21G115",
    "releaseType" : "User"
  },
  "captureTime" : "2023-02-07 18:25:11.3976 +0800",
  "incident" : "F261A133-E7F3-430E-AAF1-52A2B35A64E6",
  "bug_type" : "309",
  "pid" : 10402,
  "procExitAbsTime" : 24199274728993,
  "translated" : false,
  "cpuType" : "ARM-64",
  "procName" : "nvim",
  "procPath" : "\/opt\/homebrew\/*\/nvim",
  "parentProc" : "fish",
  "parentPid" : 9764,
  "coalitionName" : "org.alacritty",
  "crashReporterKey" : "084EC63E-4105-DEF1-67EC-007D6754BFBA",
  "responsiblePid" : 795,
  "responsibleProc" : "alacritty",
  "wakeTime" : 1070,
  "sleepWakeUUID" : "341B68BD-0AA9-4463-8464-0585AA6D5C35",
  "sip" : "disabled",
  "vmRegionInfo" : "0x18 is not in any region.  Bytes before following region: 105553518919656\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  \n      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-\/rwx SM=NUL  ...(unallocated)",
  "isCorpse" : 1,
  "exception" : {"codes":"0x0000000000000001, 0x0000000000000018","rawCodes":[1,24],"type":"EXC_BAD_ACCESS","signal":"SIGSEGV","subtype":"KERN_INVALID_ADDRESS at 0x0000000000000018"},
  "termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":10402},
  "ktriageinfo" : "VM - pmap_enter failed with resource shortage\nVM - pmap_enter failed with resource shortage\n",
  "vmregioninfo" : "0x18 is not in any region.  Bytes before following region: 105553518919656\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  \n      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-\/rwx SM=NUL  ...(unallocated)",
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":3,"thread_set_state":333,"task_for_pid":20},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"triggered":true,"id":11220071,"threadState":{"x":[{"value":5043026432},{"value":1852383343},{"value":0},{"value":0},{"value":4294967293},{"value":5041975296},{"value":0},{"value":0},{"value":0},{"value":10},{"value":0},{"value":0},{"value":1},{"value":0},{"value":1197473792},{"value":27620},{"value":6950367440,"symbolLocation":0,"symbol":"_platform_memmove"},{"value":2301},{"value":0},{"value":105553149122048},{"value":1852383343},{"value":5043307520},{"value":6122342496},{"value":4347677256,"symbolLocation":0,"symbol":"prevwin"},{"value":105553149120768},{"value":0},{"value":105553149120128},{"value":5043317569},{"value":4347677264,"symbolLocation":0,"symbol":"curwin"}],"flavor":"ARM_THREAD_STATE64","lr":{"value":4346953872},"cpsr":{"value":536875008},"fp":{"value":6122342288},"sp":{"value":6122342224},"esr":{"value":2449473542,"description":"(Data Abort) byte read Translation fault"},"pc":{"value":4346964400,"matchesCrashFrame":1},"far":{"value":24}},"queue":"com.apple.main-thread","frames":[{"imageOffset":2435504,"symbol":"frame_new_height","symbolLocation":44,"imageIndex":0},{"imageOffset":2424976,"symbol":"winframe_remove","symbolLocation":596,"imageIndex":0},{"imageOffset":2424976,"symbol":"winframe_remove","symbolLocation":596,"imageIndex":0},{"imageOffset":2444216,"symbol":"win_free_mem","symbolLocation":128,"imageIndex":0},{"imageOffset":2418764,"symbol":"win_close","symbolLocation":1824,"imageIndex":0},{"imageOffset":267212,"symbol":"nvim_win_close","symbolLocation":332,"imageIndex":0},{"imageOffset":95604,"symbol":"nlua_api_nvim_win_close","symbolLocation":380,"imageIndex":0},{"imageOffset":16084,"imageIndex":1},{"imageOffset":68092,"symbol":"lua_pcall","symbolLocation":148,"imageIndex":1},{"imageOffset":1230752,"symbol":"nlua_call_ref","symbolLocation":216,"imageIndex":0},{"imageOffset":294916,"symbol":"getnextac","symbolLocation":1188,"imageIndex":0},{"imageOffset":850040,"symbol":"do_cmdline","symbolLocation":2012,"imageIndex":0},{"imageOffset":289160,"symbol":"apply_autocmds_group","symbolLocation":1812,"imageIndex":0},{"imageOffset":2443856,"symbol":"do_autocmd_winclosed","symbolLocation":136,"imageIndex":0},{"imageOffset":2417412,"symbol":"win_close","symbolLocation":472,"imageIndex":0},{"imageOffset":307812,"symbol":"do_buffer","symbolLocation":1444,"imageIndex":0},{"imageOffset":311136,"symbol":"do_bufdel","symbolLocation":212,"imageIndex":0},{"imageOffset":889372,"symbol":"ex_bunload","symbolLocation":64,"imageIndex":0},{"imageOffset":873052,"symbol":"execute_cmd0","symbolLocation":244,"imageIndex":0},{"imageOffset":860292,"symbol":"do_cmdline","symbolLocation":12264,"imageIndex":0},{"imageOffset":1531448,"symbol":"nv_colon","symbolLocation":416,"imageIndex":0},{"imageOffset":1521760,"symbol":"normal_execute","symbolLocation":4172,"imageIndex":0},{"imageOffset":2140788,"symbol":"state_enter","symbolLocation":360,"imageIndex":0},{"imageOffset":1275556,"symbol":"main","symbolLocation":10716,"imageIndex":0},{"imageOffset":20620,"symbol":"start","symbolLocation":520,"imageIndex":2}]},{"id":11220075,"frames":[{"imageOffset":31776,"symbol":"kevent","symbolLocation":8,"imageIndex":3},{"imageOffset":89604,"symbol":"uv__io_poll","symbolLocation":760,"imageIndex":4},{"imageOffset":26576,"symbol":"uv_run","symbolLocation":252,"imageIndex":4},{"imageOffset":789980,"symbol":"loop_uv_run","symbolLocation":136,"imageIndex":0},{"imageOffset":2287336,"symbol":"tui_main","symbolLocation":708,"imageIndex":0},{"imageOffset":29292,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":5},{"imageOffset":8332,"symbol":"thread_start","symbolLocation":8,"imageIndex":5}]},{"id":11220282,"frames":[{"imageOffset":21104,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":3},{"imageOffset":30780,"symbol":"_pthread_cond_wait","symbolLocation":1236,"imageIndex":5},{"imageOffset":71512,"symbol":"uv_cond_wait","symbolLocation":12,"imageIndex":4},{"imageOffset":13248,"symbol":"worker","symbolLocation":344,"imageIndex":4},{"imageOffset":29292,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":5},{"imageOffset":8332,"symbol":"thread_start","symbolLocation":8,"imageIndex":5}]},{"id":11220283,"frames":[{"imageOffset":21104,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":3},{"imageOffset":30780,"symbol":"_pthread_cond_wait","symbolLocation":1236,"imageIndex":5},{"imageOffset":71512,"symbol":"uv_cond_wait","symbolLocation":12,"imageIndex":4},{"imageOffset":13248,"symbol":"worker","symbolLocation":344,"imageIndex":4},{"imageOffset":29292,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":5},{"imageOffset":8332,"symbol":"thread_start","symbolLocation":8,"imageIndex":5}]},{"id":11220284,"frames":[{"imageOffset":21104,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":3},{"imageOffset":30780,"symbol":"_pthread_cond_wait","symbolLocation":1236,"imageIndex":5},{"imageOffset":71512,"symbol":"uv_cond_wait","symbolLocation":12,"imageIndex":4},{"imageOffset":13248,"symbol":"worker","symbolLocation":344,"imageIndex":4},{"imageOffset":29292,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":5},{"imageOffset":8332,"symbol":"thread_start","symbolLocation":8,"imageIndex":5}]},{"id":11220285,"frames":[{"imageOffset":21104,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":3},{"imageOffset":30780,"symbol":"_pthread_cond_wait","symbolLocation":1236,"imageIndex":5},{"imageOffset":71512,"symbol":"uv_cond_wait","symbolLocation":12,"imageIndex":4},{"imageOffset":13248,"symbol":"worker","symbolLocation":344,"imageIndex":4},{"imageOffset":29292,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":5},{"imageOffset":8332,"symbol":"thread_start","symbolLocation":8,"imageIndex":5}]},{"id":11328277,"frames":[{"imageOffset":8312,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4344528896,
    "size" : 2965504,
    "uuid" : "8df66dbc-78fe-3f17-a934-78e56f9e75a4",
    "path" : "\/opt\/homebrew\/*\/nvim",
    "name" : "nvim"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4352081920,
    "size" : 458752,
    "uuid" : "7752e7ee-61de-3529-8abf-05250860a287",
    "path" : "\/opt\/homebrew\/*\/libluajit-5.1.2.1.0.dylib",
    "name" : "libluajit-5.1.2.1.0.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 4349771776,
    "size" : 393216,
    "uuid" : "38ee9fe9-b66d-3066-8c5c-6ddf0d6944c6",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6950014976,
    "size" : 229376,
    "uuid" : "a9d87740-9c1d-3468-bf60-720a8d713cba",
    "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
    "name" : "libsystem_kernel.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4350722048,
    "size" : 114688,
    "uuid" : "870e1cf7-0a62-382a-b74b-c1e970aa3db2",
    "path" : "\/opt\/homebrew\/*\/libuv.1.dylib",
    "name" : "libuv.1.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6950244352,
    "size" : 53248,
    "uuid" : "63c4eef9-69a5-38b1-996e-8d31b66a051d",
    "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
    "name" : "libsystem_pthread.dylib"
  },
  {
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  }
],
  "sharedCache" : {
  "base" : 6946947072,
  "size" : 3144744960,
  "uuid" : "049b583e-d4dc-3b2b-88da-e52d6e18313d"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=742.0M resident=0K(0%) swapped_out_or_unallocated=742.0M(100%)\nWritable regions: Total=1.7G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.7G(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nActivity Tracing                   256K        1 \nKernel Alloc Once                   32K        1 \nMALLOC                           267.2M       36 \nMALLOC guard page                   96K        4 \nMALLOC_MEDIUM (reserved)         960.0M        8         reserved VM address space (unallocated)\nMALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)\nSTACK GUARD                       56.1M        7 \nStack                             48.6M        7 \nVM_ALLOCATE                       55.2M      442 \n__AUTH                            1586K      104 \n__AUTH_CONST                      7051K      227 \n__DATA                            7361K      226 \n__DATA_CONST                      7935K      243 \n__DATA_DIRTY                       328K       81 \n__FONT_DATA                          4K        1 \n__LINKEDIT                       578.5M       20 \n__OBJC_CONST                       713K       81 \n__OBJC_RO                         83.0M        1 \n__OBJC_RW                         3168K        1 \n__TEXT                           163.5M      255 \n__UNICODE                          592K        1 \ndyld private memory               1024K        1 \nmapped file                       29.1M        3 \nshared memory                       64K        4 \n===========                     =======  ======= \nTOTAL                              2.6G     1756 \nTOTAL, minus reserved VM space     1.3G     1756 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "queue" : "com.apple.main-thread"
  }
},
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "5f72dc58705eff005a46b3a9",
      "factorPackIds" : {

      },
      "deploymentId" : 240000015
    },
    {
      "rolloutId" : "63582c5f8a53461413999550",
      "factorPackIds" : {

      },
      "deploymentId" : 240000002
    }
  ],
  "experiments" : [

  ]
}
}

```

### Steps to reproduce

Unfortunately, I don't know how to reproduce. I was just using Neovim as usual. I will describe what I did instead.

I was trying close a `diffview.nvim` window using `DiffviewClose` but it gave an error, so I hit `space x` which I mapped to `:bd`, and it crashed.

Here is [the config](https://github.com/SichangHe/.config/tree/macos/nvim) I use. I have a lot of plugins so I don't know which one of them is essential to the problem.

### Expected behavior

It should not SegFault.

### Neovim version (nvim -v)

NVIM v0.8.2

### Vim (not Nvim) behaves the same?

No idea

### Operating system/version

macOS 12.6

### Terminal name/version

alacritty 0.11.0 (8dbaa0b)

### $TERM environment variable

alacritty

### Installation

Homebrew