v-analyzer icon indicating copy to clipboard operation
v-analyzer copied to clipboard

permanent segmentation fault

Open martinskou opened this issue 9 months ago • 3 comments

Describe the bug

When starting v-analyser in vscode, a segmentation fault happen and the v-analyzer crashes.

Expected Behavior

Graceful handling of error that leads to crash.

Current Behavior

[Info - 09:45:23] v-analyzer version: 0.0.6, commit: 59a8889, OS: macos x64 [Info - 09:45:23] v-analyzer executable path: /Users/martin/Development/v-analyzer/bin/v-analyzer [Info - 09:45:23] v-analyzer build with V 610558d [Info - 09:45:23] v-analyzer build at 2025-05-15 09:40:08 [Info - 09:45:23] Client / Editor: Visual Studio Code 1.100.1 (PID: 13641) [Info - 09:45:23] Using global config: /Users/martin/.config/v-analyzer/config.toml [Info - 09:45:23] Found toolchain candidates: [Info - 09:45:23] /Users/martin/Development/v/v [Info - 09:45:23] Using "/Users/martin/Development/v/v" as toolchain [Info - 09:45:23] Using "/Users/martin/.cache/v-analyzer/59a8889_1747294829" as cache dir [Info - 09:45:23] Using "/Users/martin/.vmodules" as vmodules root. [Info - 09:45:23] Indexing /Users/martin/.vmodules [Info - 09:45:23] Indexing /Users/martin/Development/v/v/vlib signal 11: segmentation fault vlib/builtin/builtin.c.v:22: by v_segmentation_fault_handler ???:0: by ??? /Users/martin/Development/v-analyzer/src/analyzer/psi/StubList.v:30: by src.analyzer.psi.StubList_add_stub /Users/martin/Development/v-analyzer/src/analyzer/psi/StubBase.v:67: by src.analyzer.psi.new_root_stub /Users/martin/Development/v-analyzer/src/analyzer/index/StubTree.v:59: by src.analyzer.index.build_stub_tree /Users/martin/Development/v-analyzer/src/analyzer/index/IndexingRoot.v:196: by src.analyzer.index.IndexingRoot_index_file /Users/martin/Development/v-analyzer/src/analyzer/index/IndexingRoot.v:228: by anon_fn_74f72be3a50b64b8.5888 /tmp/v_501/v-analyzer.01JV9E5TG6V5JG2TYXX1FYB9XH.tmp.c:29105: by anon_fn_void.thread_wrapper ???:0: by ??? ???:0: by ??? [Error - 09:45:23] Server process exited with code 139. [Error - 09:45:23] Connection to server got closed. Server will not be restarted.

Reproduction Steps

Clean install of V and v-analyzer. Install v-analyzer plugin in vscode. Open a V project in vscode.

Possible Solution

No response

Additional Information/Context

No response

Environment details (v doctor output)

V full version V 0.4.10 ded45dce4c1c05e077d58486e90da77ec387b611
OS macos, macOS, 13.7.6, 22H625
Processor 4 cpus, 64bit, little endian, Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
Memory 2.29GB/16GB
V executable /Users/martin/Development/v/v/v
V last modified time 2025-05-15 07:44:50
V home dir OK, value: /Users/martin/Development/v/v
VMODULES OK, value: /Users/martin/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/martin/Development/projects/dead_end
Git version git version 2.49.0
V git status weekly.2025.20
.git/config present true
cc version Apple clang version 15.0.0 (clang-1500.1.0.2.5)
gcc version Apple clang version 15.0.0 (clang-1500.1.0.2.5)
clang version Apple clang version 15.0.0 (clang-1500.1.0.2.5)
tcc version tcc version 0.9.27 (x86_64 Darwin)
tcc git status thirdparty-macos-amd64 975f1ad8
emcc version N/A
glibc version N/A

Editor name

vscode

v-analyzer Version

0.0.6

VS Code Extension Version

0.0.6

martinskou avatar May 15 '25 07:05 martinskou

When running v-analyze in the terminal and connect to it using tcp, i see this output:

2025-05-15 09:56:47 [TRACE] Received data ← : Content-Length: 6169

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":13966,"clientInfo":{"name":"Visual Studio Code","version":"1.100.1"},"locale":"en","rootPath":"/Users/martin/Development/projects/dead_end","rootUri":"file:///Users/martin/Development/projects/dead_end","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"changeAnnotationSupport":{"groupsOnLabel":true}},"configuration":true,"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]},"resolveSupport":{"properties":["location.range"]}},"codeLens":{"refreshSupport":true},"executeCommand":{"dynamicRegistration":true},"didChangeConfiguration":{"dynamicRegistration":true},"workspaceFolders":true,"foldingRange":{"refreshSupport":true},"semanticTokens":{"refreshSupport":true},"fileOperations":{"dynamicRegistration":true,"didCreate":true,"didRename":true,"didDelete":true,"willCreate":true,"willRename":true,"willDelete":true},"inlineValue":{"refreshSupport":true},"inlayHint":{"refreshSupport":true},"diagnostics":{"refreshSupport":true}},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]},"codeDescriptionSupport":true,"dataSupport":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]},"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"insertTextModeSupport":{"valueSet":[1,2]},"labelDetailsSupport":true},"insertTextMode":2,"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},"completionList":{"itemDefaults":["commitCharacters","editRange","insertTextFormat","insertTextMode","data"]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true},"activeParameterSupport":true},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true,"tagSupport":{"valueSet":[1]},"labelSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"disabledSupport":true,"dataSupport":true,"resolveSupport":{"properties":["edit"]},"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"honorsChangeAnnotations":true},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true,"rangesSupport":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1,"honorsChangeAnnotations":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true,"foldingRangeKind":{"valueSet":["comment","imports","region"]},"foldingRange":{"collapsedText":false}},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":true},"semanticTokens":{"dynamicRegistration":true,"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator","decorator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"formats":["relative"],"requests":{"range":true,"full":{"delta":true}},"multilineTokenSupport":false,"overlappingTokenSupport":false,"serverCancelSupport":true,"augmentsSyntaxTokens":true},"linkedEditingRange":{"dynamicRegistration":true},"typeHierarchy":{"dynamicRegistration":true},"inlineValue":{"dynamicRegistration":true},"inlayHint":{"dynamicRegistration":true,"resolveSupport":{"properties":["tooltip","textEdits","label.tooltip","label.location","label.command"]}},"diagnostic":{"dynamicRegistration":true,"relatedDocumentSupport":false}},"window":{"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"showDocument":{"support":true},"workDoneProgress":true},"general":{"staleRequestSupport":{"cancel":true,"retryOnContentModified":["textDocument/semanticTokens/full","textDocument/semanticTokens/range","textDocument/semanticTokens/full/delta"]},"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"markdown":{"parser":"marked","version":"1.1.0","allowedTags":["ul","li","p","code","blockquote","ol","h1","h2","h3","h4","h5","h6","hr","em","pre","table","thead","tbody","tr","th","td","div","del","a","strong","br","img","span"]},"positionEncodings":["utf-16"]},"notebookDocument":{"synchronization":{"dynamicRegistration":true,"executionSummarySupport":true}},"experimental":{"serverStatusNotification":true,"viewStubTree":true}},"trace":"off","workspaceFolders":[{"uri":"file:///Users/martin/Development/projects/dead_end","name":"dead_end"}]}}

2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 136

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"v-analyzer version: 0.0.6, commit: 59a8889, OS: macos x64"}}

2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 158

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"v-analyzer executable path: /Users/martin/Development/v-analyzer/bin/v-analyzer"}}

2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 110

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"v-analyzer build with V 610558d"}}

2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 118

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"v-analyzer build at 2025-05-15 09:40:08"}}

2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 135

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Client / Editor: Visual Studio Code 1.100.1 (PID: 13966)"}}

2025-05-15 09:56:47 [INFO] v-analyzer started client_name=Visual Studio Code 1.100.1 process_id=13966 os=macos arch=x64 executable=/Users/martin/Development/v-analyzer/bin/v-analyzer build_with=610558d build_at=2025-05-15 09:40:08 build_commit=59a8889 2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 144

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Using global config: /Users/martin/.config/v-analyzer/config.toml"}}

2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 106

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Found toolchain candidates:"}}

2025-05-15 09:56:47 [INFO] Found toolchain candidates: 2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 110

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":" /Users/martin/Development/v/v"}}

2025-05-15 09:56:47 [INFO] /Users/martin/Development/v/v 2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 131

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Using "/Users/martin/Development/v/v" as toolchain"}}

2025-05-15 09:56:47 [INFO] Using "/Users/martin/Development/v/v" as toolchain 2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 152

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Using "/Users/martin/.cache/v-analyzer/59a8889_1747294829" as cache dir"}}

2025-05-15 09:56:47 [INFO] Using "/Users/martin/.cache/v-analyzer/59a8889_1747294829" as cache dir 2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 130

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Using "/Users/martin/.vmodules" as vmodules root."}}

2025-05-15 09:56:47 [INFO] Using "/Users/martin/.vmodules" as vmodules root. 2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 1715

{"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":1,"willSave":true,"save":{"includeText":false}},"hoverProvider":true,"inlayHintProvider":{"resolveProvider":false},"completionProvider":{"resolveProvider":false,"triggerCharacters":[".",":","(","@"]},"signatureHelpProvider":{"triggerCharacters":["(",","],"retriggerCharacters":[","," "]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":{"workDoneProgress":false},"documentHighlightProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix"]},"codeLensProvider":{},"documentFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"","moreTriggerCharacter":[]},"renameProvider":{"prepareProvider":false},"documentLinkProvider":{"resolveProvider":false},"colorProvider":false,"declarationProvider":false,"executeCommandProvider":{"commands":["v-analyzer.add_flag_attribute","v-analyzer.add_heap_attribute","v-analyzer.make_public","v-analyzer.make_mutable","v-analyzer.import_module"]},"foldingRangeProvider":true,"semanticTokensProvider":{"legend":{"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator","decorator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary","mutable","global"]},"range":true,"full":true},"experimental":{}},"serverInfo":{"name":"v-analyzer","version":"0.0.6"}}}

2025-05-15 09:56:47 [INFO] Request finished method=initialize duration=28.028ms 2025-05-15 09:56:47 [TRACE] Received data ← : Content-Length: 52

{"jsonrpc":"2.0","method":"initialized","params":{}}

2025-05-15 09:56:47 [INFO] -------- New session -------- 2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 97

{"jsonrpc":"2.0","method":"experimental/serverStatus","params":{"health":"ok","quiescent":false}}

2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 122

{"jsonrpc":"2.0","id": 1, "method":"window/workDoneProgress/create","params":{"token":"90aac69e6ebabd1cc5f2951941182584"}}

2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 174

{"jsonrpc":"2.0","method":"$/progress","params":{"token":"90aac69e6ebabd1cc5f2951941182584","value":{"kind":"begin","title":"Indexing:","message":"roots...","percentage":0}}}

2025-05-15 09:56:47 [INFO] Adding indexing root root=/Users/martin/.vmodules 2025-05-15 09:56:47 [INFO] Adding indexing root root=/Users/martin/Development/v/v/vlib 2025-05-15 09:56:47 [INFO] Adding indexing root root=/Users/martin/.config/v-analyzer/metadata 2025-05-15 09:56:47 [INFO] Adding indexing root root=/Users/martin/Development/projects/dead_end 2025-05-15 09:56:47 [INFO] Indexing 4 roots 2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 161

{"jsonrpc":"2.0","method":"$/progress","params":{"token":"90aac69e6ebabd1cc5f2951941182584","value":{"kind":"report","message":"1/4 (Modules)","percentage":17}}}

2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 111

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Indexing /Users/martin/.vmodules"}}

2025-05-15 09:56:47 [INFO] Indexing root root=/Users/martin/.vmodules 2025-05-15 09:56:47 [INFO] Index not found, start indexing root=/Users/martin/.vmodules 2025-05-15 09:56:47 [INFO] Indexing finished duration=34.981ms 2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 170

{"jsonrpc":"2.0","method":"$/progress","params":{"token":"90aac69e6ebabd1cc5f2951941182584","value":{"kind":"report","message":"2/4 (Standard Library)","percentage":35}}}

2025-05-15 09:56:47 [TRACE] Sent data → : Content-Length: 122

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Indexing /Users/martin/Development/v/v/vlib"}}

2025-05-15 09:56:47 [INFO] Indexing root root=/Users/martin/Development/v/v/vlib 2025-05-15 09:56:47 [INFO] Index not found, start indexing root=/Users/martin/Development/v/v/vlib signal 11: segmentation fault vlib/builtin/builtin.c.v:22: by v_segmentation_fault_handler ???:0: by ??? /Users/martin/Development/v-analyzer/src/analyzer/psi/StubList.v:30: by src.analyzer.psi.StubList_add_stub /Users/martin/Development/v-analyzer/src/analyzer/psi/StubBase.v:67: by src.analyzer.psi.new_root_stub /Users/martin/Development/v-analyzer/src/analyzer/index/StubTree.v:59: by src.analyzer.index.build_stub_tree /Users/martin/Development/v-analyzer/src/analyzer/index/IndexingRoot.v:196: by src.analyzer.index.IndexingRoot_index_file /Users/martin/Development/v-analyzer/src/analyzer/index/IndexingRoot.v:228: by anon_fn_74f72be3a50b64b8.5888 /tmp/v_501/v-analyzer.01JV9E5TG6V5JG2TYXX1FYB9XH.tmp.c:29105: by anon_fn_void.thread_wrapper ???:0: by ??? ???:0: by ???

martinskou avatar May 15 '25 07:05 martinskou

Think this i a v bug, i have reported as issue #24491 in the v repro.

in psi/StubBase.v:66 change this line:

stub_list.add_stub(mut stub, unsafe { nil })

to:

empty:= unsafe { nil }
stub_list.add_stub(mut stub, empty)

and the seg.fault disapers.

martinskou avatar May 15 '25 08:05 martinskou

The V issue was fixed https://github.com/vlang/v/issues/24491 with a cgen change.

Can you please check, if that solved this issue too?

spytheman avatar Jul 06 '25 18:07 spytheman