Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zls panic index out of bounds: index 25365, len 9918 #1595

Closed
Jarred-Sumner opened this issue Nov 11, 2023 · 3 comments
Closed

zls panic index out of bounds: index 25365, len 9918 #1595

Jarred-Sumner opened this issue Nov 11, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@Jarred-Sumner
Copy link
Contributor

Jarred-Sumner commented Nov 11, 2023

Zig Version

HEAD

Zig Language Server Version

HEAD

Steps to Reproduce

When the cursor is on this, it panics:
image

Code: https://github.com/oven-sh/bun/blob/12802557dc69fbabb9400506bcc213dddd80baf1/src/bun.js/api/bun/socket.zig#L1139

Trace:

read 12989642 panic: index out of bounds: index 25365, len 9918
/Users/jarred/Build/zls/src/analysis.zig:3165:59: 0x1010267af in iterateSymbolsContainerInternal__anon_32474 (zls)
        try analyser.iterateUsingnamespaceContainerSymbols(
                                                          ^
/Users/jarred/Build/zls/src/analysis.zig:3264:56: 0x101022163 in iterateSymbolsContainer__anon_32407 (zls)
    return try analyser.iterateSymbolsContainerInternal(container_handle, orig_handle, callback, context, instance_access);
                                                       ^
/Users/jarred/Build/zls/src/features/completions.zig:191:45: 0x100f80063 in nodeToCompletion (zls)
        try analyser.iterateSymbolsContainer(
                                            ^
/Users/jarred/Build/zls/src/features/completions.zig:75:43: 0x100f03203 in typeToCompletion (zls)
        .other => |n| try nodeToCompletion(
                                          ^
/Users/jarred/Build/zls/src/features/completions.zig:45:41: 0x100f02f8f in typeToCompletion (zls)
                    try typeToCompletion(server, analyser, arena, list, child_ty, orig_handle, null);
                                        ^
/Users/jarred/Build/zls/src/analysis.zig:3123:53: 0x10049627b in iterateSymbolsContainerInternal__anon_32474 (zls)
    const main_token = tree.nodes.items(.main_token)[container];
                                                    ^
/Users/jarred/Build/zls/src/features/completions.zig:550:25: 0x100ea0ceb in completeFieldAccess (zls)
    try typeToCompletion(server, analyser, arena, &completions, type_handle, handle, null);
                        ^
/Users/jarred/Build/zls/src/features/completions.zig:946:55: 0x100e4a12b in completionAtIndex (zls)
        .field_access => |loc| try completeFieldAccess(server, analyser, arena, handle, source_index, loc),
                                                      ^
/Users/jarred/Build/zls/src/analysis.zig:3212:69: 0x100495fd7 in iterateUsingnamespaceContainerSymbols__anon_32471 (zls)
                        try analyser.iterateSymbolsContainerInternal(
                                                                    ^
/Users/jarred/Build/zls/src/Server.zig:1257:60: 0x100dfabeb in completionHandler (zls)
        .CompletionList = try completions.completionAtIndex(server, &analyser, arena, handle, source_index) orelse return null,
                                                           ^
/Users/jarred/Build/zls/src/Server.zig:2002:68: 0x100dc629b in sendRequestSync__anon_19389 (zls)
        .@"textDocument/completion" => try server.completionHandler(arena, params),
                                                                   ^
/Users/jarred/Build/zls/src/Server.zig:2078:58: 0x100d7e01f in processMessage (zls)
                const result = try server.sendRequestSync(arena_allocator.allocator(), @tagName(method), params);
                                                         ^
/Users/jarred/Build/zls/src/Server.zig:2095:33: 0x100d297c7 in processMessageReportError (zls)
    return server.processMessage(message) catch |err| {
                                ^
/Users/jarred/Build/zls/src/Server.zig:2133:62: 0x100d00eeb in processJob (zls)
            const response = server.processMessageReportError(parsed_message.value) orelse return;
                                                             ^
/Users/jarred/zig/0.12.0-dev.1571+03adafd80/files/lib/std/Thread/Pool.zig:94:39: 0x100cfff4f in runFn (zls)
            @call(.auto, func, closure.arguments);
                                      ^
/Users/jarred/Build/zls/src/analysis.zig:3165:59: 0x1004967af in iterateSymbolsContainerInternal__anon_32474 (zls)
        try analyser.iterateUsingnamespaceContainerSymbols(
                                                          ^
/Users/jarred/zig/0.12.0-dev.1571+03adafd80/files/lib/std/Thread/Pool.zig:133:18: 0x100db1683 in worker (zls)
            runFn(&run_node.data);
                 ^
/Users/jarred/zig/0.12.0-dev.1571+03adafd80/files/lib/std/Thread.zig:412:13: 0x100d65aab in callFn__anon_17379 (zls)
            @call(.auto, f, args);
            ^
/Users/jarred/zig/0.12.0-dev.1571+03adafd80/files/lib/std/Thread.zig:685:30: 0x100d0f9c3 in entryFn (zls)
                return callFn(f, args_ptr.*);

Expected Behavior

zls should be able to show completions for values from a pub usingnamespace.

Actual Behavior

panic

@Jarred-Sumner Jarred-Sumner added the bug Something isn't working label Nov 11, 2023
@Jarred-Sumner Jarred-Sumner changed the title zls panic index out of bounds: index 25365, len 9918 in src/analysis.zig:3165 zls panic index out of bounds: index 25365, len 9918 Nov 11, 2023
@Techatrix
Copy link
Member

Does #1598 resolve your issue? Unfortunately I was unable to reproduce this crash

@Jarred-Sumner
Copy link
Contributor Author

@Techatrix yes it does! however, there are duplicates in the autocomplete list due to both usingnamespace struct implementing functions with the same call signatures

image

@Techatrix
Copy link
Member

however, there are duplicates in the autocomplete list due to both usingnamespace struct implementing functions with the same call signatures

that is #1041

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants