Skip to content

zls crashes every time on start. (.OBJECT_NAME_INVALID => unreachable) #158

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
doongjohn opened this issue Sep 15, 2020 · 5 comments · Fixed by #286
Closed

zls crashes every time on start. (.OBJECT_NAME_INVALID => unreachable) #158

doongjohn opened this issue Sep 15, 2020 · 5 comments · Fixed by #286
Assignees
Labels
bug Something isn't working

Comments

@doongjohn
Copy link

doongjohn commented Sep 15, 2020

This happens every time when I start vscode.

crash output:

reached unreachable code
D:\zig\lib\zig\std\os\windows.zig:113:37: 0x7ff6c75b7839 in std.os.windows.OpenFile (zls.obj)
            .OBJECT_NAME_INVALID => unreachable,
                                    ^
D:\zig\lib\zig\std\os.zig:4092:31: 0x7ff6c75bdd80 in std.os.realpathW (zls.obj)
        const res = w.OpenFile(pathname, .{
                              ^
D:\zig\lib\zig\std\os.zig:4040:25: 0x7ff6c75ae87d in std.os.realpath (zls.obj)
        return realpathW(pathname_w.span(), out_buffer);
                        ^
D:\zls\src\main.zig:1593:75: 0x7ff6c759481b in main (zls.obj)
            zig_exe_path = try std.mem.dupe(allocator, u8, std.os.realpath(full_path, &buf) catch continue);
                                                                          ^
D:\zig\lib\zig\std\start.zig:154:65: 0x7ff6c7591f1e in std.start.WinMainCRTStartup (zls.obj)
    std.os.windows.kernel32.ExitProcess(initEventLoopAndCallMain());
                                                                ^
Unable to dump stack trace: FileNotFound

platform: Windows 10
zls client: zls-vscode
zig version: master (0.6.0+9fe4c8923) (used to build zls)
zig is in my PATH

Edit:
Fixed by using zls.json and providing the path to zig.

I think this happened because of my antivirus software. It was not related to antivirus software.

Edit:

zls.json

{
    "zig_exe_path": "D:\\zig\\zig.exe"
}

└> this works.

{
    "zig_exe_path": "D:\\zig"
}

└> this works but can't start zig fmt process.

@alexnask alexnask self-assigned this Sep 16, 2020
@alexnask alexnask added the bug Something isn't working label Sep 16, 2020
@balenamiaa
Copy link

balenamiaa commented Oct 30, 2020

zig_exe_path = try std.mem.dupe(allocator, u8, std.os.realpath(full_path, &buf) catch continue);

This seems to be because of ziglang/zig#6044 (comment). Short term one can perhaps call https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-pathcanonicalizew on full_path before sending it to std.os.realpath as this only happens on windows AFAIK.

@alexnask
Copy link
Member

I will take a look at this, I was on a hietus for a while but I will be picking up development this week : )

@marler8997
Copy link

I've put together a potential fix here: ziglang/zig#7537

@christopher-hesse
Copy link

Following the docs on windows:

zig executable path, e.g. /path/to/zig/zig, used to run the custom build runner. If null, zig is looked up in PATH. Will be used to infer the zig standard library path if none is provided.

I set "zig_exe_path": "c:/p/third-party/zig-windows-x86_64-0.7.1/zig"

Starting zls directly has the following confusing error:

C:\p\third-party\zls-x86_64-windows\zls.exe
Content-Length: 105

{"jsonrpc":"2.0","method":"window/showMessage","params":{"type":1,"message":"[err-default] InvalidName"}}

Setting it to the directory, as this issue suggests, also does not work with a different confusing message:

"zig_exe_path": "c:/p/third-party/zig-windows-x86_64-0.7.1/"
C:\p\third-party\zls-x86_64-windows\zls.exe 
Content-Length: 106

{"jsonrpc":"2.0","method":"window/showMessage","params":{"type":1,"message":"[err-default] AccessDenied"}}

Setting it to "zig_exe_path": "c:/p/third-party/zig-windows-x86_64-0.7.1/zig.exe" seems to work:

C:\p\third-party\zls-x86_64-windows\zls.exe 
Content-Length: 164

{"jsonrpc":"2.0","method":"window/showMessage","params":{"type":3,"message":"[notice-main] Using zig lib path 'c:\\p\\third-party\\zig-windows-x86_64-0.7.1\\lib'"}}
Content-Length: 122

These error messages are confusing, and checking the config by running zls on the command line is not mentioned in the docs. Getting the errors from VSCode is even more indirect.

This was referenced Mar 30, 2021
@tau-dev
Copy link
Contributor

tau-dev commented Mar 30, 2021

Does this still happen as of the latest commit?

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

Successfully merging a pull request may close this issue.

6 participants