Himujjal/tree-sitter-svelte

Seg fault with Neovim

Closed this issue ยท 9 comments

I'm running Neovim on the latest HEAD. And since I think the last few commits it SEG faults when opening Svelte files. Any idea how I fix or debug this?

Thanks!

Process:               nvim [8532]
Path:                  /usr/local/Cellar/neovim/HEAD-0ab88c2_1/bin/nvim
Identifier:            nvim
Version:               ???
Code Type:             X86-64 (Native)
Parent Process:        zsh [2139]
OS Version:            macOS 11.2.3 (20D91)
Report Version:        12

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

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       EXC_I386_GPFLT
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [8532]

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   svelte.so                     	0x00000001042e0062 hashmap_put + 91
1   svelte.so                     	0x00000001042e02ad hashmap_put + 678
2   svelte.so                     	0x00000001042deafb tree_sitter_svelte_external_scanner_create + 939
3   libtree-sitter.0.dylib        	0x0000000103fa04d9 ts_parser_set_language + 75
4   vim                           	0x0000000103cdc2fb tslua_push_parser + 108
5   libluajit-5.1.2.dylib         	0x0000000103fd29c5 lj_BC_FUNCC + 68

Thread 1:
0   libsystem_pthread.dylib       	0x00007fff205e2458 start_wqthread + 0

Thread 2:
0   libsystem_kernel.dylib        	0x00007fff205b67e2 kevent + 10
1   libuv.1.dylib                 	0x0000000103f34461 uv__io_poll + 871
2   libuv.1.dylib                 	0x0000000103f24ec6 uv_run + 359
3   vim                           	0x0000000103c7036c loop_poll_events + 137
4   vim                           	0x0000000103dc9bf2 tui_main + 797
5   libsystem_pthread.dylib       	0x00007fff205e6950 _pthread_start + 224
6   libsystem_pthread.dylib       	0x00007fff205e247b thread_start + 15

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00000001042e0590  rcx: 0x0000000000000000  rdx: 0x656e223d66657268
  rdi: 0x0000000000000000  rsi: 0x00007ffeec037580  rbp: 0x00007ffeec037550  rsp: 0x00007ffeec0374d0
   r8: 0x00000000642d7377   r9: 0x0000000000000100  r10: 0x0000000000000000  r11: 0x0000000000050000
  r12: 0x0000000000000000  r13: 0x00007ffeec037580  r14: 0x0000000000000000  r15: 0x00007fcb380a8840
  rip: 0x00000001042e0062  rfl: 0x0000000000010246  cr2: 0x00007fcb380a9440
  
Logical CPU:     3
Error Code:      0x00000000
Trap Number:     13

Thread 0 last branch register state not available.


Binary Images:
       0x103bc2000 -        0x103e4dfff +vim (0) <297623E3-5B78-3AD4-A168-57E05941A519> /usr/local/bin/vim
       0x103f07000 -        0x103f10fff +libintl.8.dylib (0) <FA921CC0-395B-3155-8259-EA61DE25C5D2> /usr/local/opt/gettext/lib/libintl.8.dylib
       0x103f1e000 -        0x103f39fff +libuv.1.dylib (0) <AB054F09-01C5-3967-8AC3-AD2C02277737> /usr/local/opt/libuv/lib/libuv.1.dylib
       0x103f55000 -        0x103f59fff +libmsgpackc.2.dylib (0) <948223FF-9AE0-3DA0-A554-7A368A42E966> /usr/local/opt/msgpack/lib/libmsgpackc.2.dylib
       0x103f64000 -        0x103f6dfff +libvterm.0.dylib (0) <0F941D08-A254-3C55-8F40-19436071F61D> /usr/local/opt/libvterm/lib/libvterm.0.dylib
       0x103f72000 -        0x103f77fff +libtermkey.1.dylib (0) <BF173A8F-189B-36FE-883B-C2122522721B> /usr/local/opt/libtermkey/lib/libtermkey.1.dylib
       0x103f82000 -        0x103f89fff +libunibilium.4.dylib (0) <05759550-C0EC-3345-8BAD-D2A91463F56A> /usr/local/opt/unibilium/lib/libunibilium.4.dylib
       0x103f99000 -        0x103fb8fff +libtree-sitter.0.dylib (0) <20E756EB-B6BE-3B0B-AD96-B6EFCC43160B> /usr/local/opt/tree-sitter/lib/libtree-sitter.0.dylib
       0x103fcc000 -        0x10402ffff +libluajit-5.1.2.dylib (0) <540EF076-821F-3548-91EF-4144C17ABD7B> /usr/local/opt/luajit-openresty/lib/libluajit-5.1.2.dylib
       0x1042d9000 -        0x1042e0fff +svelte.so (0) <8AE79FAB-FD8A-3E1A-B02C-D3CF9A57ADC7> /Users/USER/*/svelte.so
       0x10e3ad000 -        0x10e448fff  dyld (832.7.3) <0D4EA85F-7E30-338B-9215-314A5A5539B6> /usr/lib/dyld
    0x7fff2031b000 -     0x7fff2031cfff  libsystem_blocks.dylib (78) <E644CAA0-65B7-36E4-8041-520F3301F3DB> /usr/lib/system/libsystem_blocks.dylib
    0x7fff2031d000 -     0x7fff20352fff  libxpc.dylib (2038.80.3) <70F26262-01AA-3CEC-9FAD-2701D24096F0> /usr/lib/system/libxpc.dylib
    0x7fff20353000 -     0x7fff2036afff  libsystem_trace.dylib (1277.80.2) <87FEF600-48D9-31C9-B8FC-D5249B2AE95D> /usr/lib/system/libsystem_trace.dylib
    0x7fff2036b000 -     0x7fff2040afff  libcorecrypto.dylib (1000.80.5) <1EB11CFB-ABD7-36DD-97C7-C112A6601416> /usr/lib/system/libcorecrypto.dylib
    0x7fff2040b000 -     0x7fff20437fff  libsystem_malloc.dylib (317.40.8) <A498D1EF-E43D-310C-84E8-9C0AADA0C475> /usr/lib/system/libsystem_malloc.dylib
    0x7fff20438000 -     0x7fff2047cfff  libdispatch.dylib (1271.40.12) <AD988EEA-1A2F-3404-9A6E-390FC2504223> /usr/lib/system/libdispatch.dylib
    0x7fff2047d000 -     0x7fff204b5fff  libobjc.A.dylib (818.2) <EB6B543F-D42C-3FB2-A2EC-43407C5F80D3> /usr/lib/libobjc.A.dylib
    0x7fff204b6000 -     0x7fff204b8fff  libsystem_featureflags.dylib (28.60.1) <9CECB43A-094E-3CA9-B730-24DEA1A6DE05> /usr/lib/system/libsystem_featureflags.dylib
    0x7fff204b9000 -     0x7fff20541fff  libsystem_c.dylib (1439.40.11) <4AF71812-4099-3E96-B271-1F259491A2B2> /usr/lib/system/libsystem_c.dylib
    0x7fff20542000 -     0x7fff20597fff  libc++.1.dylib (904.4) <B217D905-4F9C-3DE0-8844-88FAA3C2C851> /usr/lib/libc++.1.dylib
    0x7fff20598000 -     0x7fff205b0fff  libc++abi.dylib (904.4) <3C9FE530-3CD2-3A64-8A36-70816AEBDF0D> /usr/lib/libc++abi.dylib
    0x7fff205b1000 -     0x7fff205dffff  libsystem_kernel.dylib (7195.81.3) <AB413518-ECDE-3F04-A61C-278D3CF43076> /usr/lib/system/libsystem_kernel.dylib
    0x7fff205e0000 -     0x7fff205ebfff  libsystem_pthread.dylib (454.80.2) <B989DF6C-ADFE-3AF9-9C91-07D2521F9E47> /usr/lib/system/libsystem_pthread.dylib
    0x7fff205ec000 -     0x7fff20626fff  libdyld.dylib (832.7.3) <4641E48F-75B5-3CC7-8263-47BF79F15394> /usr/lib/system/libdyld.dylib
    0x7fff20627000 -     0x7fff20630fff  libsystem_platform.dylib (254.80.2) <1C3E1A0A-92A8-3CDE-B622-8940B43A5DF2> /usr/lib/system/libsystem_platform.dylib
    0x7fff20631000 -     0x7fff2065cfff  libsystem_info.dylib (542.40.3) <0C96CFE8-71F5-3335-8423-581BC3DE5846> /usr/lib/system/libsystem_info.dylib
    0x7fff2065d000 -     0x7fff20af8fff  com.apple.CoreFoundation (6.9 - 1774.101) <2A0E160E-9EE6-3B23-8832-6979A16EC250> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7fff227e9000 -     0x7fff22a4afff  libicucore.A.dylib (66109) <8F8D8A8B-4EE0-3C09-9F45-725A1FBDD38C> /usr/lib/libicucore.A.dylib
    0x7fff22a4b000 -     0x7fff22a54fff  libsystem_darwin.dylib (1439.40.11) <E016D8F7-C87F-36F8-B8A0-6A61B8E4BACB> /usr/lib/system/libsystem_darwin.dylib
    0x7fff22e66000 -     0x7fff22e71fff  libsystem_notify.dylib (279.40.4) <B2BF20C7-448A-3FBD-A2F5-AB7618D173F6> /usr/lib/system/libsystem_notify.dylib
    0x7fff24dc2000 -     0x7fff24dd0fff  libsystem_networkextension.dylib (1295.80.3) <5213D866-7D0E-3FD9-8E1A-03C0E39CEC44> /usr/lib/system/libsystem_networkextension.dylib
    0x7fff24e2e000 -     0x7fff24e44fff  libsystem_asl.dylib (385) <5B48071E-85EB-33B0-AE9B-127AEB398AEC> /usr/lib/system/libsystem_asl.dylib
    0x7fff2652d000 -     0x7fff26534fff  libsystem_symptoms.dylib (1431.40.36) <BC85B46C-02EE-31FF-861D-F0DE01E8F6CF> /usr/lib/system/libsystem_symptoms.dylib
    0x7fff2857d000 -     0x7fff2858dfff  libsystem_containermanager.dylib (318.80.2) <6F08275F-B912-3D8E-9D74-4845158AE4F3> /usr/lib/system/libsystem_containermanager.dylib
    0x7fff2928a000 -     0x7fff2928dfff  libsystem_configuration.dylib (1109.60.2) <4917D824-4DE8-32CC-9ED2-1FBF371FEB9F> /usr/lib/system/libsystem_configuration.dylib
    0x7fff2928e000 -     0x7fff29292fff  libsystem_sandbox.dylib (1441.60.4) <5F7F3DD1-4B38-310C-AA8F-19FF1B0F5276> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff29f96000 -     0x7fff29f98fff  libquarantine.dylib (119.40.2) <40D35D75-524B-3DA6-8159-E7E0FA66F5BC> /usr/lib/system/libquarantine.dylib
    0x7fff2a518000 -     0x7fff2a51cfff  libsystem_coreservices.dylib (127) <529A0663-A936-309C-9318-1B04B7F70658> /usr/lib/system/libsystem_coreservices.dylib
    0x7fff2a733000 -     0x7fff2a77afff  libsystem_m.dylib (3186.40.2) <DD26CC5C-AFF6-305F-A567-14909DD57163> /usr/lib/system/libsystem_m.dylib
    0x7fff2a77b000 -     0x7fff2a77bfff  libcharset.1.dylib (59) <D14F9D24-693A-37F0-8F92-D260248EB282> /usr/lib/libcharset.1.dylib
    0x7fff2a77c000 -     0x7fff2a781fff  libmacho.dylib (973.4) <C2584BC4-497B-3170-ADDF-21B8E10B4DFD> /usr/lib/system/libmacho.dylib
    0x7fff2a79e000 -     0x7fff2a7a9fff  libcommonCrypto.dylib (60178.40.2) <822A29CE-BF54-35AD-BB15-8FAECB800C7D> /usr/lib/system/libcommonCrypto.dylib
    0x7fff2a7aa000 -     0x7fff2a7b4fff  libunwind.dylib (200.10) <1D0A4B4A-4370-3548-8DC1-42A7B4BD45D3> /usr/lib/system/libunwind.dylib
    0x7fff2a7b5000 -     0x7fff2a7bcfff  liboah.dylib (203.30) <44C477D9-013F-3A6D-A9FE-68A89214E6A5> /usr/lib/liboah.dylib
    0x7fff2a7bd000 -     0x7fff2a7c7fff  libcopyfile.dylib (173.40.2) <39DBE613-135B-3AFE-A6AF-7898A37F70C2> /usr/lib/system/libcopyfile.dylib
    0x7fff2a7c8000 -     0x7fff2a7cffff  libcompiler_rt.dylib (102.2) <62EE1D14-5ED7-3CEC-81C0-9C93833641F1> /usr/lib/system/libcompiler_rt.dylib
    0x7fff2a7d0000 -     0x7fff2a7d2fff  libsystem_collections.dylib (1439.40.11) <C53D5E0C-0C4F-3B35-A24B-E0D7101A3F95> /usr/lib/system/libsystem_collections.dylib
    0x7fff2a7d3000 -     0x7fff2a7d5fff  libsystem_secinit.dylib (87.60.1) <E05E35BC-1BAB-365B-8BEE-D774189EFD3B> /usr/lib/system/libsystem_secinit.dylib
    0x7fff2a7d6000 -     0x7fff2a7d8fff  libremovefile.dylib (49.40.3) <5CC12A16-82CB-32F0-9040-72CFC88A48DF> /usr/lib/system/libremovefile.dylib
    0x7fff2a7d9000 -     0x7fff2a7d9fff  libkeymgr.dylib (31) <803F6AED-99D5-3CCF-B0FA-361BCF14C8C0> /usr/lib/system/libkeymgr.dylib
    0x7fff2a7da000 -     0x7fff2a7e1fff  libsystem_dnssd.dylib (1310.80.1) <E0A0CAB3-6779-3C83-AC67-046CFE69F9C2> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff2a7e2000 -     0x7fff2a7e7fff  libcache.dylib (83) <1A98B064-8FED-39CF-BB2E-5BDA1EF5B65A> /usr/lib/system/libcache.dylib
    0x7fff2a7e8000 -     0x7fff2a7e9fff  libSystem.B.dylib (1292.60.1) <83503CE0-32B1-36DB-A4F0-3CC6B7BCF50A> /usr/lib/libSystem.B.dylib
    0x7fff2a7ea000 -     0x7fff2a7edfff  libfakelink.dylib (3) <D939A124-9FD5-37A2-B03B-72E98CBC98FE> /usr/lib/libfakelink.dylib
    0x7fff2a7ee000 -     0x7fff2a7eefff  com.apple.SoftLinking (1.0 - 1) <EF2AC5FF-B98D-3252-ABA8-2FC721CBA942> /System/Library/PrivateFrameworks/SoftLinking.framework/Versions/A/SoftLinking
    0x7fff2a827000 -     0x7fff2a917fff  libiconv.2.dylib (59) <AD10ECF4-E137-3152-9612-7EC548D919E8> /usr/lib/libiconv.2.dylib
    0x7fff2af8f000 -     0x7fff2af92fff  libutil.dylib (58.40.2) <0A268749-08E7-3551-8969-442210651CCA> /usr/lib/libutil.dylib
    0x7fff2dc21000 -     0x7fff2dc21fff  liblaunch.dylib (2038.80.3) <C7C51322-8491-3B78-9CFA-2B4753662BCF> /usr/lib/system/liblaunch.dylib
    0x7fff300d5000 -     0x7fff300d5fff  libsystem_product_info_filter.dylib (8.40.1) <20310EE6-2C3F-361A-9ECA-4223AFC03B65> /usr/lib/system/libsystem_product_info_filter.dylib

Thanks for bringing this to my notice. I recently ported tree-sitter-svelte from stable C++ code to c99 due to some build constraints of a library I was working on. Might have caused this issue. Let me do some edits and I will let you know. In the meantime, if possible use this tree:

https://github.com/Himujjal/tree-sitter-svelte/tree/a5f16a5995b0c1ab2e3d09ff074e02bcc8c8e5d1

ah! was about to make this issue as well :)
I don't know any C so I am sorry that I couldn't help

in the meantime, I'll continue to use the c++ tree

@jgelens In the meantime can you post your Svelte file for the same? For testing. Maybe I missed some characters or something.

Yes sure:
[...slug].svelte.zip

The strange thing is, is that it doesn't always crash, sometimes it just loads fine. Just now I had to open it 5 times before crashing.

I was having that situation as well, but now it just crashed right away even after opening an empty file

sheredom/hashmap.h#20

I was using this library and this issue was causing the problem. Anyways. Fixed it. I am able to run the svelte files as expected. Also I have updated queries thanks to @elianiva . So, :TSInstallFromGrammar svelte will do the trick I guess

Can you guys try and report it to me? @jgelens @elianiva Its working for me though.

And oh. I forgot. Use the dev branch.

@Himujjal Looks promising! I reopened the file several times now without problems. I will continue using it today and let you know :)

Sure. Finally its working it seems

updated master and created a merge request to nvim-treesitter.

Now you can do :TSInstall svelte directly