zls icon indicating copy to clipboard operation
zls copied to clipboard

infinite loop on struct init field completion

Open techatrix opened this issue 3 years ago • 1 comments

Zig Version

0.11.0-dev.4320+6f0a613b6

Zig Language Server Version

f2207016849a74715c8f1f99779d789097087b68

Steps to Reproduce

_ = .{} .shift = .{ .<ask for completions here>shift

Expected Behavior

don't crash duh

Actual Behavior

zls.exe!getPositionContext(@typeInfo(@typeInfo(@TypeOf(analysis.getPositionContext)).Fn.return_type.?).ErrorUnion.error_set!analysis.PositionContext * allocator, builtin.StackTrace * text, mem.Allocator * doc_index, []u8 lookahead, unsigned __int64) Line 2283 (c:\Users\Techatrix\zls\src\analysis.zig:2283)
zls.exe!resolveContainer(error{OutOfMemory}![]analysis.TypeWithHandle * document_store, builtin.StackTrace * analyser, DocumentStore * arena, analysis * handle, mem.Allocator * text_index, DocumentStore.Handle * fn_arg_index, unsigned __int64) Line 848 (c:\Users\Techatrix\zls\src\features\completions.zig:848)
zls.exe!resolveContainer(error{OutOfMemory}![]analysis.TypeWithHandle * document_store, builtin.StackTrace * analyser, DocumentStore * arena, analysis * handle, mem.Allocator * text_index, DocumentStore.Handle * fn_arg_index, unsigned __int64) Line 1052 (c:\Users\Techatrix\zls\src\features\completions.zig:1052)
zls.exe!resolveContainer(error{OutOfMemory}![]analysis.TypeWithHandle * document_store, builtin.StackTrace * analyser, DocumentStore * arena, analysis * handle, mem.Allocator * text_index, DocumentStore.Handle * fn_arg_index, unsigned __int64) Line 917 (c:\Users\Techatrix\zls\src\features\completions.zig:917)
this repeats over a thousand times here...
zls.exe!resolveContainer(error{OutOfMemory}![]analysis.TypeWithHandle * document_store, builtin.StackTrace * analyser, DocumentStore * arena, analysis * handle, mem.Allocator * text_index, DocumentStore.Handle * fn_arg_index, unsigned __int64) Line 1052 (c:\Users\Techatrix\zls\src\features\completions.zig:1052)
zls.exe!resolveContainer(error{OutOfMemory}![]analysis.TypeWithHandle * document_store, builtin.StackTrace * analyser, DocumentStore * arena, analysis * handle, mem.Allocator * text_index, DocumentStore.Handle * fn_arg_index, unsigned __int64) Line 917 (c:\Users\Techatrix\zls\src\features\completions.zig:917)
zls.exe!resolveContainer(error{OutOfMemory}![]analysis.TypeWithHandle * document_store, builtin.StackTrace * analyser, DocumentStore * arena, analysis * handle, mem.Allocator * text_index, DocumentStore.Handle * fn_arg_index, unsigned __int64) Line 1052 (c:\Users\Techatrix\zls\src\features\completions.zig:1052)
zls.exe!completeDot(error{OutOfMemory}![]lsp.CompletionItem * document_store, builtin.StackTrace * analyser, DocumentStore * arena, analysis * handle, mem.Allocator * source_index, DocumentStore.Handle *) Line 1196 (c:\Users\Techatrix\zls\src\features\completions.zig:1196)
zls.exe!completionAtIndex(error{OutOfMemory}!?lsp.CompletionList * server, builtin.StackTrace * analyser, Server * arena, analysis * handle, mem.Allocator * source_index, DocumentStore.Handle *) Line 1316 (c:\Users\Techatrix\zls\src\features\completions.zig:1316)
zls.exe!completionHandler(error{OutOfMemory,ParseError,InvalidRequest,MethodNotFound,InvalidParams,InternalError,ServerNotInitialized,RequestFailed,ServerCancelled,ContentModified,RequestCancelled}!?lsp.request_metadata__union_13923 * server, builtin.StackTrace * arena, Server * request, mem.Allocator *) Line 850 (c:\Users\Techatrix\zls\src\Server.zig:850)
zls.exe!sendRequestSync__anon_21582(error{OutOfMemory,ParseError,InvalidRequest,MethodNotFound,InvalidParams,InternalError,ServerNotInitialized,RequestFailed,ServerCancelled,ContentModified,RequestCancelled}!?lsp.request_metadata__union_13923 * server, builtin.StackTrace * arena, Server * params, mem.Allocator *) Line 1614 (c:\Users\Techatrix\zls\src\Server.zig:1614)
zls.exe!processMessage(error{OutOfMemory,ParseError,InvalidRequest,MethodNotFound,InvalidParams,InternalError,ServerNotInitialized,RequestFailed,ServerCancelled,ContentModified,RequestCancelled}!?[]u8 * server, builtin.StackTrace * message, Server *) Line 1692 (c:\Users\Techatrix\zls\src\Server.zig:1692)
zls.exe!processMessageReportError(Server * server, Server.Message * message) Line 1711 (c:\Users\Techatrix\zls\src\Server.zig:1711)
zls.exe!processJob(Server * server, Server.Job * job, Thread.WaitGroup * wait_group) Line 1735 (c:\Users\Techatrix\zls\src\Server.zig:1735)
zls.exe!runFn(Thread.Pool.Runnable * runnable) Line 97 (e:\Software\zig-windows-x86_64-0.11.0-dev.4320+6f0a613b6\lib\std\Thread\Pool.zig:97)
zls.exe!worker(Thread.Pool * pool) Line 133 (e:\Software\zig-windows-x86_64-0.11.0-dev.4320+6f0a613b6\lib\std\Thread\Pool.zig:133)
zls.exe!callFn__anon_19258(struct{*Thread.Pool} * args) Line 413 (e:\Software\zig-windows-x86_64-0.11.0-dev.4320+6f0a613b6\lib\std\Thread.zig:413)
zls.exe!00007ff6172634a5() Line 524 (e:\Software\zig-windows-x86_64-0.11.0-dev.4320+6f0a613b6\lib\std\Thread.zig:524)
kernel32.dll!00007ff988687614() (Unknown Source:0)
ntdll.dll!00007ff9887c26f1() (Unknown Source:0)

techatrix avatar Aug 01 '23 03:08 techatrix

Yes, most exit conditions in that function are "generic"; an if (depth > -1) return null; after the find_identifier: while (upper_index > 0) { block should prevent this one.

llogick avatar Aug 01 '23 14:08 llogick