Skip to content

@import breaking on windows when using disk in path #1816

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

Closed
Darkfllame opened this issue Mar 4, 2024 · 1 comment
Closed

@import breaking on windows when using disk in path #1816

Darkfllame opened this issue Mar 4, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Darkfllame
Copy link

Zig Version

0.12.0-dev.2990+31763d28c

Zig Language Server Version

845a9a0

Client / Code Editor / Extensions

windows with vscode and the Zig Language extension

Steps to Reproduce and Observed Behavior

So I needed to get the Config struct of the GeneralPurposeAllocator, but the standard library doesn't exposes it, so I wanted to import it with the raw path, with the driver letter all the way down to where my zig standard library is. But zls crashes with the message :

The Zig Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

The step to reproduce is easy, just use a driver letter in the import path:

const GPA = @import("C:/Zig64/lib/std/heap/general_purpose_allocator.zig");

Expected Behavior

Well obiously it should have not crash and effectively load the file C:/Zig64/lib/std/heap/general_purpose_allocator.zig

Relevant log output

thread 10204 panic: reached unreachable code
C:\Zig64\lib\std\os\windows.zig:123:37: 0xa078c1 in OpenFile (zls.exe.obj)
            .OBJECT_NAME_INVALID => unreachable,
                                    ^
C:\Zig64\lib\std\fs\Dir.zig:879:33: 0x9e4ffe in openFileW (zls.exe.obj)
        .handle = try w.OpenFile(sub_path_w, .{
                                ^
C:\Zig64\lib\std\fs\Dir.zig:765:30: 0x98802a in openFile (zls.exe.obj)
        return self.openFileW(path_w.span(), flags);
                             ^
C:\Zig64\lib\std\fs\Dir.zig:1784:33: 0xb7a506 in readFileAllocOptions__anon_28740 (zls.exe.obj)
    var file = try self.openFile(file_path, .{});
                                ^
C:\Zig64\zls\src\DocumentStore.zig:659:60: 0xb27700 in getOrLoadHandle (zls.exe.obj)
    const file_contents = std.fs.cwd().readFileAllocOptions(self.allocator, file_path, max_document_size, null, @alignOf(u8), 0) catch |err| {
                                                           ^
C:\Zig64\zls\src\analysis.zig:1682:66: 0xb865ab in resolveTypeOfNodeUncached (zls.exe.obj)
                const new_handle = analyser.store.getOrLoadHandle(import_uri) orelse return null;
                                                                 ^
C:\Zig64\zls\src\analysis.zig:1200:54: 0xb2a4bb in resolveTypeOfNodeInternal (zls.exe.obj)
    const ty = try analyser.resolveTypeOfNodeUncached(node_handle);
                                                     ^
C:\Zig64\zls\src\analysis.zig:1240:62: 0xb81a1a in resolveTypeOfNodeUncached (zls.exe.obj)
                return try analyser.resolveTypeOfNodeInternal(value) orelse break :blk;
                                                             ^
C:\Zig64\zls\src\analysis.zig:1200:54: 0xb2a4bb in resolveTypeOfNodeInternal (zls.exe.obj)
    const ty = try analyser.resolveTypeOfNodeUncached(node_handle);
                                                     ^
C:\Zig64\zls\src\analysis.zig:1186:46: 0xb28d80 in resolveTypeOfNode (zls.exe.obj)
    return analyser.resolveTypeOfNodeInternal(node_handle);
                                             ^
C:\Zig64\zls\src\features\inlay_hints.zig:225:65: 0xb6a08f in typeStrOfNode (zls.exe.obj)
    const resolved_type = try builder.analyser.resolveTypeOfNode(.{ .handle = builder.handle, .node = node }) orelse return null;
                                                                ^
C:\Zig64\zls\src\features\inlay_hints.zig:358:34: 0xb1886c in writeNodeInlayHint (zls.exe.obj)
                try typeStrOfNode(builder, node) orelse return,
                                 ^
C:\Zig64\zls\src\ast.zig:1738:25: 0xb6de5b in recursive_callback (zls.exe.obj)
            try callback(@as(*const @TypeOf(context), @alignCast(@ptrCast(ctx))).*, ast, child_node);
                        ^
C:\Zig64\zls\src\ast.zig:1496:29: 0xb6c33b in iterateChildrenTypeErased (zls.exe.obj)
                try callback(context, tree, child);
                            ^
C:\Zig64\zls\src\ast.zig:1743:34: 0xb1964e in iterateChildrenRecursive__anon_25744 (zls.exe.obj)
    if (iterateChildrenTypeErased(tree, node, @ptrCast(&context), RecursiveContext.recursive_callback)) |_| {
                                 ^
C:\Zig64\zls\src\features\inlay_hints.zig:483:41: 0xac7456 in writeRangeInlayHint (zls.exe.obj)
        try ast.iterateChildrenRecursive(handle.tree, child, &builder, error{OutOfMemory}, writeNodeInlayHint);
                                        ^
C:\Zig64\zls\src\Server.zig:1465:47: 0xa8d4de in inlayHintHandler (zls.exe.obj)
    return try inlay_hints.writeRangeInlayHint(
                                              ^
C:\Zig64\zls\src\Server.zig:1914:66: 0xa626ec in sendRequestSync__anon_19973 (zls.exe.obj)
        .@"textDocument/inlayHint" => try server.inlayHintHandler(arena, params),
                                                                 ^
C:\Zig64\zls\src\Server.zig:1991:58: 0xa1b621 in processMessage (zls.exe.obj)
                const result = try server.sendRequestSync(arena_allocator.allocator(), @tagName(method), params);
                                                         ^
C:\Zig64\zls\src\Server.zig:2008:33: 0x9b1d2b in processMessageReportError (zls.exe.obj)
    return server.processMessage(message) catch |err| {
                                ^
C:\Zig64\zls\src\Server.zig:2046:62: 0x98154b in processJob (zls.exe.obj)
            const response = server.processMessageReportError(parsed_message.value) orelse return;
debug: (server                                                             ^
): Took 33ms to process request-3-textDocument/codeAction on Thread 10084
C:\Zig64\lib\std\Thread\Pool.zig:93:39: 0x980890 in runFn (zls.exe.obj)
            @call(.auto, func, closure.arguments);
                                      ^
C:\Zig64\lib\std\Thread\Pool.zig:132:18: 0xa4b8a8 in worker (zls.exe.obj)
            runFn(&run_node.data);
                 ^
C:\Zig64\lib\std\Thread.zig:411:13: 0x9f77ec in callFn__anon_17993 (zls.exe.obj)
            @call(.auto, f, args);
            ^
C:\Zig64\lib\std\Thread.zig:523:30: 0x9918fe in entryFn (zls.exe.obj)
                return callFn(f, self.fn_args);
                             ^
???:?:?: 0x7fff9fdc53df in ??? (KERNEL32.DLL)
???:?:?: 0x7fffa0ce485a in ??? (ntdll.dll)
@Darkfllame Darkfllame added the bug Something isn't working label Mar 4, 2024
@llogick
Copy link
Contributor

llogick commented Apr 14, 2024

@llogick llogick closed this as completed Apr 14, 2024
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