nvim-neotest / neotest

An extensible framework for interacting with tests within NeoVim.
MIT License
2.45k stars 123 forks source link

[BUG] nvim crashes after trying use neotest #158

Open Malefaro opened 2 years ago

Malefaro commented 2 years ago

NeoVim Version NVIM v0.8.0 Build type: Release LuaJIT 2.1.0-beta3

On macos monterey 12.4 m1 pro

Describe the bug When opening nvim and trying to call a summary or run a nearest test, nvim crashes with a segfault error. This happens inconstantly, but even if nvim doesn't crash it displays "no tests found". However if summary opens with "no tests found", after saving, the tests are found and run without errors. This happends in neotest-go and neotest-python.

The issue was in nvim v0.7 too. Plugins have been updated. Crashes occur only in this scenario.

Logs Nothing special. Run with log_level=1. No ERROR messages.

Additional context Backtrace

Translated Report (Full Report Below)
-------------------------------------

Process:               nvim [75149]
Path:                  /Volumes/VOLUME/*/nvim
Identifier:            nvim
Version:               ???
Code Type:             ARM-64 (Native)
Parent Process:        zsh [9960]
User ID:               501

Date/Time:             2022-11-18 00:55:52.4911 +0300
OS Version:            macOS 12.4 (21F79)
Report Version:        12
Anonymous UUID:        4359633D-9651-B59D-2D25-CA3377886766

Sleep/Wake UUID:       862BB119-FA6C-452D-AE24-D002D457468A

Time Awake Since Boot: 630000 seconds
Time Since Wake:       5182 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000948d4f4c8960 -> 0x0000148d4f4c8960 (possible pointer authentication failure)
Exception Codes:       0x0000000000000001, 0x0000948d4f4c8960
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [75149]

VM Region Info: 0x148d4f4c8960 is not in any region.  Bytes after previous region: 22116117023073  Bytes before following region: 82955962906272
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      commpage (reserved)        1000000000-7000000000   [384.0G] ---/--- SM=NUL  ...(unallocated)
--->  GAP OF 0x5f9000000000 BYTES
      MALLOC_NANO              600000000000-600008000000 [128.0M] rw-/rwx SM=PRV  

Kernel Triage:
VM - pmap_enter failed with resource shortage

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   ???                                    0x1026ee5e8 luv_push_dirent + 48
1   ???                                    0x1026ee5e8 luv_push_dirent + 48
2   ???                                    0x1026ee430 push_fs_result + 796
3   ???                                    0x1026edfc8 luv_fs_cb + 44
4   ???                                    0x10270c570 uv__work_done + 192
5   ???                                    0x10270fd60 uv__async_io + 320
6   ???                                    0x102722d7c uv__io_poll + 1060
7   ???                                    0x102710310 uv_run + 396
8   ???                                    0x10237142c loop_poll_events + 92
9   ???                                    0x102460750 inbuf_poll + 404
10  ???                                    0x10246042c os_inchar + 284
11  ???                                    0x1024ef620 state_enter + 264
12  ???                                    0x10242e018 normal_enter + 140
13  ???                                    0x1023ed418 main + 9020
14  dyld                                   0x10275d08c start + 520

Thread 1:
0   libsystem_kernel.dylib                 0x1b82c8c20 kevent + 8
1   ???                                    0x102722c68 uv__io_poll + 784
2   ???                                    0x102710310 uv_run + 396
3   ???                                    0x102371448 loop_poll_events + 120
4   ???                                    0x102513278 tui_main + 556
5   libsystem_pthread.dylib                0x1b830026c _pthread_start + 148
6   libsystem_pthread.dylib                0x1b82fb08c thread_start + 8

Thread 2:
0   libsystem_kernel.dylib                 0x1b82c6270 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1b830083c _pthread_cond_wait + 1236
2   ???                                    0x10271d988 uv_cond_wait + 12
3   ???                                    0x10270c8ac worker + 112
4   libsystem_pthread.dylib                0x1b830026c _pthread_start + 148
5   libsystem_pthread.dylib                0x1b82fb08c thread_start + 8

Thread 3:
0   libsystem_kernel.dylib                 0x1b82c6270 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1b830083c _pthread_cond_wait + 1236
2   ???                                    0x10271d988 uv_cond_wait + 12
3   ???                                    0x10270c8ac worker + 112
4   libsystem_pthread.dylib                0x1b830026c _pthread_start + 148
5   libsystem_pthread.dylib                0x1b82fb08c thread_start + 8

Thread 4:
0   libsystem_kernel.dylib                 0x1b82c6270 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1b830083c _pthread_cond_wait + 1236
2   ???                                    0x10271d988 uv_cond_wait + 12
3   ???                                    0x10270c8ac worker + 112
4   libsystem_pthread.dylib                0x1b830026c _pthread_start + 148
5   libsystem_pthread.dylib                0x1b82fb08c thread_start + 8

Thread 5:
0   libsystem_kernel.dylib                 0x1b82c6270 __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1b830083c _pthread_cond_wait + 1236
2   ???                                    0x10271d988 uv_cond_wait + 12
3   ???                                    0x10270c8ac worker + 112
4   libsystem_pthread.dylib                0x1b830026c _pthread_start + 148
5   libsystem_pthread.dylib                0x1b82fb08c thread_start + 8

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000102bac590   x1: 0x0000000000000040   x2: 0x0000000000000000   x3: 0x0000000000000040
    x4: 0x0000000000000030   x5: 0x0000000000000030   x6: 0x000000000000003a   x7: 0x0000000000000000
    x8: 0x0000000104345e60   x9: 0x0000000104346290  x10: 0x0000000102bac580  x11: 0x00000001029b00d8
   x12: 0x0000000102fbf9a8  x13: 0x0000000000000070  x14: 0x00000000000000d4  x15: 0xfffffffffffffff7
   x16: 0x0000000102a634dc  x17: 0x0000000104345e50  x18: 0x0000000000000000  x19: 0x00000001029b0380
   x20: 0x0000000000000001  x21: 0x0000948d4f4c8960  x22: 0x0000000000000002  x23: 0x0000600000648940
   x24: 0x0000000000000020  x25: 0x0000000000000001  x26: 0x0000000000000001  x27: 0x00000001025f9bc0
   x28: 0x0000000000000001   fp: 0x000000016db3dd70   lr: 0x00000001026ee5e8
    sp: 0x000000016db3dd50   pc: 0x00000001026ee5e8 cpsr: 0x80001000
   far: 0x0000948d4f4c8960  esr: 0x92000004 (Data Abort) byte read Translation fault

Binary Images:
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
       0x102758000 -        0x1027b7fff dyld (*) <d9c2a46e-8dc4-3950-9d6a-f799e8ccb683> /usr/lib/dyld
       0x1b82c1000 -        0x1b82f8fff libsystem_kernel.dylib (*) <03f48dc5-caa7-3678-af61-1a3c7fa8b06e> /usr/lib/system/libsystem_kernel.dylib
       0x1b82f9000 -        0x1b8305fff libsystem_pthread.dylib (*) <42166a2c-89a9-3c38-a215-f028544cea23> /usr/lib/system/libsystem_pthread.dylib

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: 18
    thread_create: 0
    thread_set_state: 260

VM Region Summary:
ReadOnly portion of Libraries: Total=660.8M resident=0K(0%) swapped_out_or_unallocated=660.8M(100%)
Writable regions: Total=1.9G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.9G(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                   256K        1 
Kernel Alloc Once                   32K        1 
MALLOC                           298.2M       39 
MALLOC guard page                   96K        5 
MALLOC_MEDIUM (reserved)           1.2G       10         reserved VM address space (unallocated)
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
STACK GUARD                       56.1M        6 
Stack                             48.1M        6 
VM_ALLOCATE                       19.8M      160 
__AUTH                             220K       44 
__AUTH_CONST                      2907K      123 
__DATA                            1249K      128 
__DATA_CONST                      3872K      136 
__DATA_DIRTY                       233K       50 
__LINKEDIT                       578.1M       17 
__OBJC_CONST                       260K       29 
__OBJC_RO                         83.0M        1 
__OBJC_RW                         3152K        1 
__TEXT                            82.7M      144 
__UNICODE                          592K        1 
dyld private memory               1024K        1 
mapped file                        160K        1 
shared memory                       32K        2 
===========                     =======  ======= 
TOTAL                              2.7G      907 
TOTAL, minus reserved VM space     1.2G      907 

-----------
Full Report
-----------

{"app_name":"nvim","timestamp":"2022-11-18 00:55:52.00 +0300","app_version":"","slice_uuid":"00000000-0000-0000-0000-000000000000","build_version":"","platform":1,"share_with_app_devs":0,"is_first_party":1,"bug_type":"309","os_version":"macOS 12.4 (21F79)","incident_id":"34DC5EC2-15EC-48C3-B332-9C5B1EDCB2DC","name":"nvim"}
{
  "uptime" : 630000,
  "procLaunch" : "2022-11-18 00:55:50.3628 +0300",
  "procRole" : "Unspecified",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "MacBookPro18,3",
  "procStartAbsTime" : 15200455961685,
  "coalitionID" : 1275,
  "osVersion" : {
    "train" : "macOS 12.4",
    "build" : "21F79",
    "releaseType" : "User"
  },
  "captureTime" : "2022-11-18 00:55:52.4911 +0300",
  "incident" : "34DC5EC2-15EC-48C3-B332-9C5B1EDCB2DC",
  "bug_type" : "309",
  "pid" : 75149,
  "procExitAbsTime" : 15200506960011,
  "translated" : false,
  "cpuType" : "ARM-64",
  "procName" : "nvim",
  "procPath" : "\/Volumes\/VOLUME\/*\/nvim",
  "parentProc" : "zsh",
  "parentPid" : 9960,
  "coalitionName" : "net.kovidgoyal.kitty",
  "crashReporterKey" : "4359633D-9651-B59D-2D25-CA3377886766",
  "responsiblePid" : 2318,
  "wakeTime" : 5182,
  "sleepWakeUUID" : "862BB119-FA6C-452D-AE24-D002D457468A",
  "sip" : "enabled",
  "vmRegionInfo" : "0x148d4f4c8960 is not in any region.  Bytes after previous region: 22116117023073  Bytes before following region: 82955962906272\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      commpage (reserved)        1000000000-7000000000   [384.0G] ---\/--- SM=NUL  ...(unallocated)\n--->  GAP OF 0x5f9000000000 BYTES\n      MALLOC_NANO              600000000000-600008000000 [128.0M] rw-\/rwx SM=PRV  ",
  "isCorpse" : 1,
  "exception" : {"codes":"0x0000000000000001, 0x0000948d4f4c8960","rawCodes":[1,163334641715552],"type":"EXC_BAD_ACCESS","signal":"SIGSEGV","subtype":"KERN_INVALID_ADDRESS at 0x0000948d4f4c8960 -> 0x0000148d4f4c8960 (possible pointer authentication failure)"},
  "termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":75149},
  "ktriageinfo" : "VM - pmap_enter failed with resource shortage\n",
  "vmregioninfo" : "0x148d4f4c8960 is not in any region.  Bytes after previous region: 22116117023073  Bytes before following region: 82955962906272\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      commpage (reserved)        1000000000-7000000000   [384.0G] ---\/--- SM=NUL  ...(unallocated)\n--->  GAP OF 0x5f9000000000 BYTES\n      MALLOC_NANO              600000000000-600008000000 [128.0M] rw-\/rwx SM=PRV  ",
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":260,"task_for_pid":18},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"triggered":true,"id":44132552,"threadState":{"x":[{"value":4340762000},{"value":64},{"value":0},{"value":64},{"value":48},{"value":48},{"value":58},{"value":0},{"value":4365508192},{"value":4365509264},{"value":4340761984},{"value":4338680024},{"value":4345035176},{"value":112},{"value":212},{"value":18446744073709551607},{"value":4339414236,"symbolLocation":0,"symbol":"lua_settop"},{"value":4365508176},{"value":0},{"value":4338680704},{"value":1},{"value":163334641715552},{"value":2},{"value":105553122855232},{"value":32},{"value":1},{"value":1},{"value":4334787520,"symbolLocation":536,"symbol":"main_loop"},{"value":1}],"flavor":"ARM_THREAD_STATE64","lr":{"value":4335789544},"cpsr":{"value":2147487744},"fp":{"value":6135471472},"sp":{"value":6135471440},"esr":{"value":2449473540,"description":"(Data Abort) byte read Translation fault"},"pc":{"value":4335789544,"matchesCrashFrame":1},"far":{"value":163334641715552}},"queue":"com.apple.main-thread","frames":[{"imageOffset":4335789544,"symbol":"luv_push_dirent","symbolLocation":48,"imageIndex":0},{"imageOffset":4335789544,"symbol":"luv_push_dirent","symbolLocation":48,"imageIndex":0},{"imageOffset":4335789104,"symbol":"push_fs_result","symbolLocation":796,"imageIndex":0},{"imageOffset":4335787976,"symbol":"luv_fs_cb","symbolLocation":44,"imageIndex":0},{"imageOffset":4335912304,"symbol":"uv__work_done","symbolLocation":192,"imageIndex":0},{"imageOffset":4335926624,"symbol":"uv__async_io","symbolLocation":320,"imageIndex":0},{"imageOffset":4336004476,"symbol":"uv__io_poll","symbolLocation":1060,"imageIndex":0},{"imageOffset":4335928080,"symbol":"uv_run","symbolLocation":396,"imageIndex":0},{"imageOffset":4332131372,"symbol":"loop_poll_events","symbolLocation":92,"imageIndex":0},{"imageOffset":4333111120,"symbol":"inbuf_poll","symbolLocation":404,"imageIndex":0},{"imageOffset":4333110316,"symbol":"os_inchar","symbolLocation":284,"imageIndex":0},{"imageOffset":4333696544,"symbol":"state_enter","symbolLocation":264,"imageIndex":0},{"imageOffset":4332904472,"symbol":"normal_enter","symbolLocation":140,"imageIndex":0},{"imageOffset":4332639256,"symbol":"main","symbolLocation":9020,"imageIndex":0},{"imageOffset":20620,"symbol":"start","symbolLocation":520,"imageIndex":1}]},{"id":44132553,"frames":[{"imageOffset":31776,"symbol":"kevent","symbolLocation":8,"imageIndex":2},{"imageOffset":4336004200,"symbol":"uv__io_poll","symbolLocation":784,"imageIndex":0},{"imageOffset":4335928080,"symbol":"uv_run","symbolLocation":396,"imageIndex":0},{"imageOffset":4332131400,"symbol":"loop_poll_events","symbolLocation":120,"imageIndex":0},{"imageOffset":4333843064,"symbol":"tui_main","symbolLocation":556,"imageIndex":0},{"imageOffset":29292,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":3},{"imageOffset":8332,"symbol":"thread_start","symbolLocation":8,"imageIndex":3}]},{"id":44133212,"frames":[{"imageOffset":21104,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":2},{"imageOffset":30780,"symbol":"_pthread_cond_wait","symbolLocation":1236,"imageIndex":3},{"imageOffset":4335982984,"symbol":"uv_cond_wait","symbolLocation":12,"imageIndex":0},{"imageOffset":4335913132,"symbol":"worker","symbolLocation":112,"imageIndex":0},{"imageOffset":29292,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":3},{"imageOffset":8332,"symbol":"thread_start","symbolLocation":8,"imageIndex":3}]},{"id":44133213,"frames":[{"imageOffset":21104,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":2},{"imageOffset":30780,"symbol":"_pthread_cond_wait","symbolLocation":1236,"imageIndex":3},{"imageOffset":4335982984,"symbol":"uv_cond_wait","symbolLocation":12,"imageIndex":0},{"imageOffset":4335913132,"symbol":"worker","symbolLocation":112,"imageIndex":0},{"imageOffset":29292,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":3},{"imageOffset":8332,"symbol":"thread_start","symbolLocation":8,"imageIndex":3}]},{"id":44133214,"frames":[{"imageOffset":21104,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":2},{"imageOffset":30780,"symbol":"_pthread_cond_wait","symbolLocation":1236,"imageIndex":3},{"imageOffset":4335982984,"symbol":"uv_cond_wait","symbolLocation":12,"imageIndex":0},{"imageOffset":4335913132,"symbol":"worker","symbolLocation":112,"imageIndex":0},{"imageOffset":29292,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":3},{"imageOffset":8332,"symbol":"thread_start","symbolLocation":8,"imageIndex":3}]},{"id":44133215,"frames":[{"imageOffset":21104,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":2},{"imageOffset":30780,"symbol":"_pthread_cond_wait","symbolLocation":1236,"imageIndex":3},{"imageOffset":4335982984,"symbol":"uv_cond_wait","symbolLocation":12,"imageIndex":0},{"imageOffset":4335913132,"symbol":"worker","symbolLocation":112,"imageIndex":0},{"imageOffset":29292,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":3},{"imageOffset":8332,"symbol":"thread_start","symbolLocation":8,"imageIndex":3}]}],
  "usedImages" : [
  {
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 4336222208,
    "size" : 393216,
    "uuid" : "d9c2a46e-8dc4-3950-9d6a-f799e8ccb683",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7384862720,
    "size" : 229376,
    "uuid" : "03f48dc5-caa7-3678-af61-1a3c7fa8b06e",
    "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
    "name" : "libsystem_kernel.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7385092096,
    "size" : 53248,
    "uuid" : "42166a2c-89a9-3c38-a215-f028544cea23",
    "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
    "name" : "libsystem_pthread.dylib"
  }
],
  "sharedCache" : {
  "base" : 7381794816,
  "size" : 3136077824,
  "uuid" : "513553bb-5ca5-3b9e-a613-b0603ffe3038"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=660.8M resident=0K(0%) swapped_out_or_unallocated=660.8M(100%)\nWritable regions: Total=1.9G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.9G(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nActivity Tracing                   256K        1 \nKernel Alloc Once                   32K        1 \nMALLOC                           298.2M       39 \nMALLOC guard page                   96K        5 \nMALLOC_MEDIUM (reserved)           1.2G       10         reserved VM address space (unallocated)\nMALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)\nSTACK GUARD                       56.1M        6 \nStack                             48.1M        6 \nVM_ALLOCATE                       19.8M      160 \n__AUTH                             220K       44 \n__AUTH_CONST                      2907K      123 \n__DATA                            1249K      128 \n__DATA_CONST                      3872K      136 \n__DATA_DIRTY                       233K       50 \n__LINKEDIT                       578.1M       17 \n__OBJC_CONST                       260K       29 \n__OBJC_RO                         83.0M        1 \n__OBJC_RW                         3152K        1 \n__TEXT                            82.7M      144 \n__UNICODE                          592K        1 \ndyld private memory               1024K        1 \nmapped file                        160K        1 \nshared memory                       32K        2 \n===========                     =======  ======= \nTOTAL                              2.7G      907 \nTOTAL, minus reserved VM space     1.2G      907 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "queue" : "com.apple.main-thread"
  }
},
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "60356660bbe37970735c5624",
      "factorPackIds" : {

      },
      "deploymentId" : 240000027
    },
    {
      "rolloutId" : "60186475825c62000ccf5450",
      "factorPackIds" : {

      },
      "deploymentId" : 240000026
    }
  ],
  "experiments" : [

  ]
}
}
tyoung-patreon commented 2 years ago

I pinned to v1.35.0 and this wasn't happening there, but I was getting segfaults on v1.37.4 so it's likely between those two versions. I tested with latest plenary and neotest-python

rcarriga commented 2 years ago

I need something to reproduce, I haven't experienced this. Please provide the logs and a minimal init file.

Initial guess would be something with the neovim subprocess since that was introduced in 1.37.0. If you want to test locally you can comment out this line https://github.com/nvim-neotest/neotest/blob/63d180622545316922ab94215a3a0049d5458621/lua/neotest/client/init.lua#L336 to avoid starting the subprocess

Malefaro commented 2 years ago

neotest.log clear log after crash

Malefaro commented 2 years ago

I need something to reproduce, I haven't experienced this. Please provide the logs and a minimal init file.

Initial guess would be something with the neovim subprocess since that was introduced in 1.37.0. If you want to test locally you can comment out this line

https://github.com/nvim-neotest/neotest/blob/63d180622545316922ab94215a3a0049d5458621/lua/neotest/client/init.lua#L336

to avoid starting the subprocess

still crashes after comment out this line

rcarriga commented 2 years ago

I'm afraid the logs don't tell me enough on their own, I'll still need a init.lua

Malefaro commented 2 years ago
vim.cmd [[packadd packer.nvim]]
vim.g.mapleader = ","
vim.opt.termencoding = 'UTF-8'
vim.opt.encoding = 'UTF-8'
vim.opt.shiftwidth = 4
vim.opt.softtabstop = 4
vim.opt.tabstop = 4
vim.opt.expandtab = true
vim.opt.autoread = true
-- line length
vim.opt.colorcolumn = "100"
-- for gitgutter
vim.opt.updatetime = 100
vim.opt.mouse = 'a'
vim.opt.mousemodel = 'popup'
vim.opt.cursorline = true
vim.opt.hlsearch = true
vim.opt.incsearch = true
vim.opt.list = true

map = vim.api.nvim_set_keymap
opts = { noremap = true, silent = true }
for _, mode in pairs({ 'n', 'v' }) do
    map(mode, 'J', '5j', {})
    map(mode, 'K', '5k', {})
    map(mode, 'L', '3l', {})
    map(mode, 'H', '3h', {})
end
map('n', '<C-s>', '<C-[>', {})
for _, mode in pairs({ 'i', 'v', 'c', 't', 'o', 's', 'x' }) do
    map(mode, '<C-s>', '<C-[>', { noremap = true })
end
map('n', '<C-s>', ':w<CR>', opts)
map('n', 'dq', ':q<CR>', {})
map('t', '<C-j>', '<Down>', {})
map('t', '<C-k>', '<Up>', {})

vim.cmd [[
filetype plugin on
set number
set backspace=2

set clipboard+=unnamedplus

inoremap <expr><C-j> pumvisible() ? "\<Down>" : "\<C-n>"
inoremap <expr><C-k> pumvisible() ? "\<Up>" : "\<C-p>"

" exist to normal mode in terminal
tnoremap <Esc> <C-\><C-n>

nmap <silent> <ESC> :nohlsearch<CR>

au BufWritePost *.py :silent !black %
set completeopt+=noinsert
]]

map = vim.api.nvim_set_keymap
opts = { noremap = true, silent = true }

require("packer").startup(function(use)
    use 'wbthomason/packer.nvim'

    use { 'nvim-neotest/neotest', requires = "antoinemadec/FixCursorHold.nvim" }
    use 'nvim-neotest/neotest-go'
    use 'nvim-neotest/neotest-python'
    use 'nvim-neotest/neotest-plenary'
    use 'vim-test/vim-test'

    use {
        'nvim-treesitter/nvim-treesitter',
        run = ':TSUpdate',
        config = function()
            local ts = require('nvim-treesitter.configs')
            ts.setup {
                ensure_installed = { "python", "go", "rust", "lua" },
                highlight = {
                    enable = true,
                }
            }
        end
    }
    use 'nvim-lua/plenary.nvim'
end)

vim.api.nvim_command("PackerCompile")

require('neotest').setup({
    floating = {
        border = "rounded",
        max_height = 0.85,
        max_width = 0.85,
        options = {}
    },
    log_level = 1,
    adapters = {
        require('neotest-python')({
            dap = { justMyCode = false },
            args = { "--dc=Local", "--ds=gateway.settings_local", "--color=yes", "--reuse-db" }
        }),
        require('neotest-go')({
            args = { "-count=1", "-timeout=60s" }
        }),
        require('neotest-plenary'),
    },
})

local map = vim.api.nvim_set_keymap
map('n', '<leader>tn', '<cmd>lua require("neotest").run.run()<cr>', {})
map('n', '<leader>td', '<cmd>lua require("neotest").run.run({strategy="dap"})<cr>', {})
map('n', '<leader>ts', '<cmd>lua require("neotest").summary.toggle()<cr>', {})
map('n', '<leader>to', '<cmd>lua require("neotest").output.open({enter=true})<cr>', {})
map('n', '<leader>ta', '<cmd>lua require("neotest").run.attach()<cr>', {})
map('n', '<leader>tf', '<cmd>lua require("neotest").run.run(vim.fn.expand("%"))<cr>', {})
map('n', '<leader>te', '<cmd>lua require("neotest").run.stop()<cr>', {})
Malefaro commented 2 years ago

Crashes happens since 1.37.2 (on 1.37.1 everything is fine)

rcarriga commented 2 years ago

Thanks for that, but I still can't reproduce.

That's great that it's narrowed down to 1.37.2. The main change of that version was the refactoring of the file finding logic which would make sense as a problematic area as there are a lot of system calls. There could be a platform specific problem or it could be that it's reading too many files.

Could you experiment with different size repos? I've tested with fairly large repos myself and not had issues but every system is different. I've added a new log line to show which directories are being scanned which will hopefully help pinpoint the issue

Malefaro commented 2 years ago

With small size repo everything works fine with python project it scans 200+ dirs with go project it scans 600+ dirs (but it scans vendor dir with library code that does not contains tests) Intresting part: there is always different number of scanned dirs. (I clear log before each run). Even if its not crashed and output "no tests found" its does not scan all dirs. By the way. If nvim not crashed and output "no tests found", after save it finds tests but only in current file

rcarriga commented 2 years ago

with go project it scans 600+ dirs (but it scans vendor dir with library code that does not contains tests)

You can filter directories that will be scanned to avoid doing this. If it's a common thing in go to have that then maybe the adapter should do that by default, so would be worth opening an issue.

By the way. If nvim not crashed and output "no tests found", after save it finds tests but only in current file

That makes sense, it's discovered the file by matching the buffer rather than through the file system so it circumvents this issue.

If it doesn't crash, do you see any error in the logs saying Couldn't find positions in path ...? Also does tweaking the max entries value here https://github.com/nvim-neotest/neotest/blob/9a950675a2284558c56aea7ba9522ae642495e3d/lua/neotest/lib/file/find.lua#L24 have any effect? Set it to something like 10

If we can't figure this out, I may put back the old discovery code that worked for you previously and allow using it under an option in the config.

compactcode commented 1 year ago

I am also experiencing this issue. I have been using the latest versions for a while with Arch Linux but hit this one when I switched to using NixOS on the same machine.

Version 1.37.1 works fine and 1.37.2 crashes fairly reliably or produces "No tests found".

Happy to provide logs etc but not sure how to produce them.

rcarriga commented 1 year ago

What neovim version are you using on NixOS?

In your config set log_level = vim.log.levels.DEBUG. The log file can be found at :echo stdpath("log"). Wipe any existing logs before reproducing and then paste the file here :smile:

cesrjimenez commented 1 year ago

Same problem here. Not in NixOS. It just crashes nvim whenever I run any neotest command.

ERROR | 2023-03-22T21:26:15Z-0600 | ...pack/packer/start/neotest/lua/neotest/lib/subprocess.lua:30 | Child process is waiting for input at startup. Aborting.
ERROR | 2023-03-22T21:46:32Z-0600 | ...pack/packer/start/neotest/lua/neotest/lib/subprocess.lua:30 | Child process is waiting for input at startup. Aborting.

DEBUG | 2023-03-22T21:55:52Z-0600 | ...te/pack/packer/start/neotest/lua/neotest/config/init.lua:306 | User config {
  adapters = { {
      _generate_position_id = <function 1>,
      build_spec = <function 2>,
      discover_positions = <function 3>,
      is_test_file = <function 4>,
      name = "neotest-go",
      results = <function 5>,
      root = <function 6>,
      <metatable> = {
        __call = <function 7>
      }
    } },
  benchmark = {
    enabled = true
  },
  consumers = {},
  default_strategy = "integrated",
  diagnostic = {
    enabled = true,
    severity = 1
  },
  discovery = {
    concurrent = 14,
    enabled = true
  },
  floating = {
    border = "rounded",
    max_height = 0.6,
    max_width = 0.6,
    options = {}
  },
  highlights = {
    adapter_name = "NeotestAdapterName",
    border = "NeotestBorder",
    dir = "NeotestDir",
    expand_marker = "NeotestExpandMarker",
    failed = "NeotestFailed",
    file = "NeotestFile",
    focused = "NeotestFocused",
    indent = "NeotestIndent",
    marked = "NeotestMarked",
    namespace = "NeotestNamespace",
    passed = "NeotestPassed",
    running = "NeotestRunning",
    select_win = "NeotestWinSelect",
    skipped = "NeotestSkipped",
    target = "NeotestTarget",
    test = "NeotestTest",
    unknown = "NeotestUnknown"
  },
  icons = {
    child_indent = "│",
    child_prefix = "├",
    collapsed = "─",
    expanded = "╮",
    failed = "",
    final_child_indent = " ",
    final_child_prefix = "╰",
    non_collapsible = "─",
    passed = "",
    running = "",
    running_animated = { "/", "|", "\\", "-", "/", "|", "\\", "-" },
    skipped = "",
    unknown = ""
  },
  jump = {
    enabled = true
  },
  log_level = 1,
  output = {
    enabled = true,
    open_on_run = "short"
  },
  output_panel = {
    enabled = true,
    open = "botright split | resize 15"
  },
  projects = {
    <metatable> = {
      __index = <function 8>
    }
  },
  quickfix = {
    enabled = true,
    open = true
  },
  run = {
    enabled = true
  },
  running = {
    concurrent = true
  },
  state = {
    enabled = true
  },
  status = {
    enabled = true,
    signs = true,
    virtual_text = false
  },
  strategies = {
    integrated = {
      height = 40,
      width = 120
    }
  },
  summary = {
    animated = true,
    enabled = true,
    expand_errors = true,
    follow = true,
    mappings = {
      attach = "a",
      clear_marked = "M",
      clear_target = "T",
      debug = "d",
      debug_marked = "D",
      expand = { "<CR>", "<2-LeftMouse>" },
      expand_all = "e",
      jumpto = "i",
      mark = "m",
      next_failed = "J",
      output = "o",
      prev_failed = "K",
      run = "r",
      run_marked = "R",
      short = "O",
      stop = "u",
      target = "t"
    },
    open = "botright vsplit | vertical resize 50"
  }
}
INFO | 2023-03-22T21:56:09Z-0600 | ...te/pack/packer/start/neotest/lua/neotest/config/init.lua:305 | Configuration complete
DEBUG | 2023-03-22T21:56:09Z-0600 | ...te/pack/packer/start/neotest/lua/neotest/config/init.lua:306 | User config {
  adapters = { {
      _generate_position_id = <function 1>,
      build_spec = <function 2>,
      discover_positions = <function 3>,
      is_test_file = <function 4>,
      name = "neotest-go",
      results = <function 5>,
      root = <function 6>,
      <metatable> = {
        __call = <function 7>
      }
    } },
  benchmark = {
    enabled = true
  },
  consumers = {},
  default_strategy = "integrated",
  diagnostic = {
    enabled = true,
    severity = 1
  },
  discovery = {
    concurrent = 14,
    enabled = true
  },
  floating = {
    border = "rounded",
    max_height = 0.6,
    max_width = 0.6,
    options = {}
  },
  highlights = {
    adapter_name = "NeotestAdapterName",
    border = "NeotestBorder",
    dir = "NeotestDir",
    expand_marker = "NeotestExpandMarker",
    failed = "NeotestFailed",
    file = "NeotestFile",
    focused = "NeotestFocused",
    indent = "NeotestIndent",
    marked = "NeotestMarked",
    namespace = "NeotestNamespace",
    passed = "NeotestPassed",
    running = "NeotestRunning",
    select_win = "NeotestWinSelect",
    skipped = "NeotestSkipped",
    target = "NeotestTarget",
    test = "NeotestTest",
    unknown = "NeotestUnknown"
  },
  icons = {
    child_indent = "│",
    child_prefix = "├",
    collapsed = "─",
    expanded = "╮",
    failed = "",
    final_child_indent = " ",
    final_child_prefix = "╰",
    non_collapsible = "─",
    passed = "",
    running = "",
    running_animated = { "/", "|", "\\", "-", "/", "|", "\\", "-" },
    skipped = "",
    unknown = ""
  },
  jump = {
    enabled = true
  },
  log_level = 1,
  output = {
    enabled = true,
    open_on_run = "short"
  },
  output_panel = {
    enabled = true,
    open = "botright split | resize 15"
  },
  projects = {
    <metatable> = {
      __index = <function 8>
    }
  },
  quickfix = {
    enabled = true,
    open = true
  },
  run = {
    enabled = true
  },
  running = {
    concurrent = true
  },
  state = {
    enabled = true
  },
  status = {
    enabled = true,
    signs = true,
    virtual_text = false
  },
  strategies = {
    integrated = {
      height = 40,
      width = 120
    }
  },
  summary = {
    animated = true,
    enabled = true,
    expand_errors = true,
    follow = true,
    mappings = {
      attach = "a",
      clear_marked = "M",
      clear_target = "T",
      debug = "d",
      debug_marked = "D",
      expand = { "<CR>", "<2-LeftMouse>" },
      expand_all = "e",
      jumpto = "i",
      mark = "m",
      next_failed = "J",
      output = "o",
      prev_failed = "K",
      run = "r",
      run_marked = "R",
      short = "O",
      stop = "u",
      target = "t"
    },
    open = "botright vsplit | vertical resize 50"
  }
}
INFO | 2023-03-22T21:56:31Z-0600 | ...pack/packer/start/neotest/lua/neotest/lib/subprocess.lua:32 | Starting child process
INFO | 2023-03-22T21:56:31Z-0600 | ...pack/packer/start/neotest/lua/neotest/lib/subprocess.lua:35 | Parent address: localhost:58983
INFO | 2023-03-22T21:56:31Z-0600 | ...pack/packer/start/neotest/lua/neotest/lib/subprocess.lua:41 | Starting child process with command: /usr/local/Cellar/neovim/0.8.3/bin/nvim --embed --headless
ERROR | 2023-03-22T21:56:32Z-0600 | ...pack/packer/start/neotest/lua/neotest/lib/subprocess.lua:56 | Child process is waiting for input at startup. Aborting.
INFO | 2023-03-22T21:56:37Z-0600 | ...te/pack/packer/start/neotest/lua/neotest/config/init.lua:305 | Configuration complete
DEBUG | 2023-03-22T21:56:37Z-0600 | ...te/pack/packer/start/neotest/lua/neotest/config/init.lua:306 | User config {
  adapters = { {
      _generate_position_id = <function 1>,
      build_spec = <function 2>,
      discover_positions = <function 3>,
      is_test_file = <function 4>,
      name = "neotest-go",
      results = <function 5>,
      root = <function 6>,
      <metatable> = {
        __call = <function 7>
      }
    } },
  benchmark = {
    enabled = true
  },
  consumers = {},
  default_strategy = "integrated",
  diagnostic = {
    enabled = true,
    severity = 1
  },
  discovery = {
    concurrent = 14,
    enabled = true
  },
  floating = {
    border = "rounded",
    max_height = 0.6,
    max_width = 0.6,
    options = {}
  },
  highlights = {
    adapter_name = "NeotestAdapterName",
    border = "NeotestBorder",
    dir = "NeotestDir",
    expand_marker = "NeotestExpandMarker",
    failed = "NeotestFailed",
    file = "NeotestFile",
    focused = "NeotestFocused",
    indent = "NeotestIndent",
    marked = "NeotestMarked",
    namespace = "NeotestNamespace",
    passed = "NeotestPassed",
    running = "NeotestRunning",
    select_win = "NeotestWinSelect",
    skipped = "NeotestSkipped",
    target = "NeotestTarget",
    test = "NeotestTest",
    unknown = "NeotestUnknown"
  },
  icons = {
    child_indent = "│",
    child_prefix = "├",
    collapsed = "─",
    expanded = "╮",
    failed = "",
    final_child_indent = " ",
    final_child_prefix = "╰",
    non_collapsible = "─",
    passed = "",
    running = "",
    running_animated = { "/", "|", "\\", "-", "/", "|", "\\", "-" },
    skipped = "",
    unknown = ""
  },
  jump = {
    enabled = true
  },
  log_level = 1,
  output = {
    enabled = true,
    open_on_run = "short"
  },
  output_panel = {
    enabled = true,
    open = "botright split | resize 15"
  },
  projects = {
    <metatable> = {
      __index = <function 8>
    }
  },
  quickfix = {
    enabled = true,
    open = true
  },
  run = {
    enabled = true
  },
  running = {
    concurrent = true
  },
  state = {
    enabled = true
  },
  status = {
    enabled = true,
    signs = true,
    virtual_text = false
  },
  strategies = {
    integrated = {
      height = 40,
      width = 120
    }
  },
  summary = {
    animated = true,
    enabled = true,
    expand_errors = true,
    follow = true,
    mappings = {
      attach = "a",
      clear_marked = "M",
      clear_target = "T",
      debug = "d",
      debug_marked = "D",
      expand = { "<CR>", "<2-LeftMouse>" },
      expand_all = "e",
      jumpto = "i",
      mark = "m",
      next_failed = "J",
      output = "o",
      prev_failed = "K",
      run = "r",
      run_marked = "R",
      short = "O",
      stop = "u",
      target = "t"
    },
    open = "botright vsplit | vertical resize 50"
  }
}

It just hangs so don't know if its the logs from the hanguing.

Happy to provide any other logs that are needed.

compactcode commented 1 year ago

I did some experimenting and found that this problem only seems to occur for me on larger code-bases.

Smaller ruby project, works fine

List of source files.

❯ fd | wc -l            
252

List of all files including those in .gitignore (tmp, node_modules etc)

❯ fd --no-ignore | wc -l           
12128

Larger ruby project, does not work

❯ fd | wc -l            
8260
❯ fd --no-ignore | wc -l
100402

One thing I notice in the logs is that neotest is scanning all the non source code files in .gitignore.

DEBUG | 2023-03-24T11:44:08Z+1100 | .../pack/packer/start/neotest/lua/neotest/lib/file/find.lua:30 | Scanning directory: tmp
DEBUG | 2023-03-24T11:44:08Z+1100 | .../pack/packer/start/neotest/lua/neotest/lib/file/find.lua:30 | Scanning directory: node_modules

Those directories contain an enourmous amount of junk that might be clogging neotest up?

✦ ❯ fd --no-ignore . node_modules/ | wc -l
26996

✦ ❯ fd --no-ignore . tmp/ | wc -l         
65115

Idea

I wonder if there might be something in adding an ability to either ignore directories or respect a .gitignore file? Perhaps this already exists?

compactcode commented 1 year ago

What neovim version are you using on NixOS?

❯ nvim --version
NVIM v0.9.0-dev-c6f8af3
Build type: Release
LuaJIT 2.1.0-beta3

Currently using nightly but had the same issue on 0.8.1.

rcarriga commented 1 year ago

Ah yes @compactcode it looks like your adapters don't define a suitable filter_dir function https://github.com/nvim-neotest/neotest/blob/bbbfa55d850f1aaa6707ea85fb5230ac866459c6/lua/neotest/adapters/interface.lua#L14-L20 I would raise the issue for them so all users benefit but you can provide a custom one in the neotest setup

neotest.setup({
discovery = {
  filter_dir = function(name, rel_path, root)
    return name ~= "node_modules"
  end,
},
...

@Numbers88s Are you also seeing this on large projects? I've tested with 100000 files myself and still had no issue so still not sure what the exact cause is

compactcode commented 1 year ago

I tried filter_dir which did remove the node_modules scan. Unfortunately the issue still persists.

rcarriga commented 1 year ago

Can you provide logs?

kxccc commented 1 year ago

I also encountered a similar segmentation fault on NixOS. When I "Run the nearest test", there is no problem, but when I "Debug the nearest test", a segmentation fault occurs. The version of nvim is 0.8.1.

f4z3r commented 1 year ago

I am also having this issue. It seems that this is related to the subprocess that is initialized (with nvim --headless --embed) is stuck in blocking mode (waiting for input). The main process then hangs because

https://github.com/nvim-neotest/neotest/blob/80f9c963019dc72d46574ff0ccb9a428f232afc5/lua/neotest/lib/subprocess.lua#L55-L58 logs an error but does not throw an error up the call stack. As far as I understand this then blocks at the next RPC call.

I modified the file throwing a random error after the error log, which seems to work as a workaround, but means I am not delegating stuff to the child process. I have no idea why the child nvim process is stuck in blocking mode though ...

rcarriga commented 1 year ago

Thanks for pointing out that it wasn't aborting, just logging that it was :facepalm: Added a fix for that at least

I have no idea why the child nvim process is stuck in blocking mode though ...

If you run nvim --embed --headless, do you see anything printed?

f4z3r commented 1 year ago

f you run nvim --embed --headless, do you see anything printed?

Nope I do not. Should I? I also tried running with nvim --embed --headless -u NONE to ensure it is not linked to my configurasion, but it also does not print anything.

Amleto commented 1 year ago

Just as an additional data point, I see the crash for the dotnet plug on a small local repo - ~50 source files. It happens every time for me.

The error that shows up in my main log is:

ERR 2023-07-15T15:54:50.045 nvim.15864.0 pty_process_spawn:133: pty_process_spawn(C:/Program\ Files/Git/usr/bin/bash.exe): os_conpty_spawn failed: error code: 2