zls
                                
                                 zls copied to clipboard
                                
                                    zls copied to clipboard
                            
                            
                            
                        crash report
Using sublime with a fresh zls build pulled and built today, i've been having more crashes than usual with -Drelease-safe build. So i made a debug build and it crashed right away. Here is what i'm seeing from the Tools->LSP->Toggle Panel output.
Hope this is somehow helpful. Let me know if I can provide any more into.
# the version of zig i used to build zls. pulled/built from master on Jul 29
$ zig version
0.10.0-dev.3378+b3d0694fc
[info-main] Setting configuration...
[info-config] Using zig executable ~/zig/zig/build/zig
[debug-main] Took 0ms to process method textDocument/documentHighlight
:: <-  zig window/logMessage: {'message': '[info-main] Setting configuration...', 'type': 3}
:: <-  zig window/logMessage: {'message': '[info-config] Using zig executable ~/zig/zig/build/zig', 'type': 3}
:: <<< zig 2: None
:: <-  zig window/logMessage: {'message': '[debug-main] Took 0ms to process method textDocument/documentHighlight', 'type': 4}
thread 685319 panic: reached unreachable code
~/zig/lib/std/debug.zig:281:14: 0x2ae93b in std.debug.assert (zls)
    if (!ok) unreachable; // assertion failure
             ^
~/zig/lib/std/zig/Ast.zig:120:11: 0x39ee7d in std.zig.Ast.tokenSlice (zls)
    assert(token.tag == token_tag);
          ^
~/zls/src/references.zig:418:44: 0x41feb4 in references.symbolReferencesInternal (zls)
            const rhs_str = tree.tokenSlice(datas[node].rhs);
                                           ^
~/zls/src/references.zig:230:41: 0x41c9c2 in references.symbolReferencesInternal (zls)
            try symbolReferencesInternal(arena, store, .{ .node = if_node.ast.then_expr, .handle = handle }, decl, encoding, context, handler);
                                        ^
~/zls/src/references.zig:116:45: 0x41b767 in references.symbolReferencesInternal (zls)
                try symbolReferencesInternal(arena, store, .{ .node = var_decl.ast.init_node, .handle = handle }, decl, encoding, context, handler);
                                            ^
~/zls/src/references.zig:85:45: 0x41b46b in references.symbolReferencesInternal (zls)
                try symbolReferencesInternal(arena, store, .{ .node = stmt, .handle = handle }, decl, encoding, context, handler);
                                            ^
~/zls/src/references.zig:219:41: 0x41c7d6 in references.symbolReferencesInternal (zls)
            try symbolReferencesInternal(arena, store, .{ .node = loop.ast.then_expr, .handle = handle }, decl, encoding, context, handler);
                                        ^
~/zls/src/references.zig:85:45: 0x41b46b in references.symbolReferencesInternal (zls)
                try symbolReferencesInternal(arena, store, .{ .node = stmt, .handle = handle }, decl, encoding, context, handler);
                                            ^
~/zls/src/references.zig:219:41: 0x41c7d6 in references.symbolReferencesInternal (zls)
            try symbolReferencesInternal(arena, store, .{ .node = loop.ast.then_expr, .handle = handle }, decl, encoding, context, handler);
                                        ^
~/zls/src/references.zig:85:45: 0x41b46b in references.symbolReferencesInternal (zls)
                try symbolReferencesInternal(arena, store, .{ .node = stmt, .handle = handle }, decl, encoding, context, handler);
                                            ^
~/zls/src/references.zig:219:41: 0x41c7d6 in references.symbolReferencesInternal (zls)
            try symbolReferencesInternal(arena, store, .{ .node = loop.ast.then_expr, .handle = handle }, decl, encoding, context, handler);
                                        ^
~/zls/src/references.zig:85:45: 0x41b46b in references.symbolReferencesInternal (zls)
                try symbolReferencesInternal(arena, store, .{ .node = stmt, .handle = handle }, decl, encoding, context, handler);
                                            ^
~/zls/src/references.zig:168:45: 0x41f0e5 in references.symbolReferencesInternal (zls)
                try symbolReferencesInternal(arena, store, .{ .node = datas[node].rhs, .handle = handle }, decl, encoding, context, handler);
                                            ^
~/zls/src/references.zig:104:45: 0x41b5ed in references.symbolReferencesInternal (zls)
                try symbolReferencesInternal(arena, store, .{ .node = member, .handle = handle }, decl, encoding, context, handler);
                                            ^
~/zls/src/references.zig:116:45: 0x41b767 in references.symbolReferencesInternal (zls)
                try symbolReferencesInternal(arena, store, .{ .node = var_decl.ast.init_node, .handle = handle }, decl, encoding, context, handler);
                                            ^
~/zls/src/references.zig:104:45: 0x41b5ed in references.symbolReferencesInternal (zls)
                try symbolReferencesInternal(arena, store, .{ .node = member, .handle = handle }, decl, encoding, context, handler);
                                            ^
~/zls/src/references.zig:504:41: 0x41a310 in references.symbolReferences (zls)
            try symbolReferencesInternal(arena, store, .{ .node = 0, .handle = curr_handle }, decl_handle, encoding, context, handler);
                                        ^
~/zls/src/Server.zig:1139:36: 0x32cae3 in referencesDefinitionGlobal (zls)
    try references.symbolReferences(
                                   ^
~/zls/src/Server.zig:2337:65: 0x307bdc in documentHighlightHandler (zls)
            .var_access => try server.referencesDefinitionGlobal(arena, id, handle, doc_position.absolute_index, true, true),
                                                                ^
~/zls/src/Server.zig:2515:53: 0x2fe726 in processJsonRpc (zls)
                    done = extractErr(method_info[2](server, arena, id, request_obj));
                                                    ^
~/zls/src/Server.zig:2586:34: 0x2e1025 in loop (zls)
        try server.processJsonRpc(&arena, &json_parser, buf);
                                 ^
~/zls/src/Server.zig:2698:20: 0x2d9ea5 in main (zls)
    try server.loop();
                   ^
~/zig/lib/std/start.zig:576:37: 0x2b27d3 in std.start.posixCallMainAndExit (zls)
            const result = root.main() catch |err| {
                                    ^
~/zig/lib/std/start.zig:338:5: 0x2b2562 in std.start._start (zls)
    @call(.{ .modifier = .never_inline }, posixCallMainAndExit, .{});
    ^
Could you provide us with the text file that caused this issue? Preferably one that has been reduced to the smallest possible size while still reproducing the crash, which is also helpful if you don't want to show us your private code.
Seems like a lot of people have been experiencing this, seems like new behavior.
I am switching back to the debug build again (from release-fast - which doesn't crash). I will post some repro code when i see it crash.
Just wanted to let you guys know that i have been using a debug build for a few days and haven't seen many crashes. While I haven't been able reproduce the issue, I suspect that it has something to do with anytype parameters or generics. The last crash i had, i was changing some code from using a file.reader() to a std.io.bufferedReader(). While its just a hunch, just thought i would share incase its helpful.
I'll keep using the debug build and trying to reproduce.
I've gone back to using a release fast build of zls and haven't found any useful source code reproductions. So I'm closing this issue as I can't provide any useful feedback. Although i still see many crashes (including release fast builds). Will re-open this or make another issue if I discover any.
One thing i will say I've discovered is that pasting random text into a zig buffer will usually crash zls whereas typing in the same text doesn't cause a crash. But I can't really provide a reproduction for this.