Skip to content

ZLS does not build with master #15376

Closed

Description

@leecannon

Zig Version

0.11.0-dev.2680+a1aa55ebe

Steps to Reproduce and Observed Behavior

This issue has only just started occuring, build works fine with 0.11.0-dev.2666+1e207f1ed

$ git clone --recurse-submodules https://github.com/zigtools/zls.git
$ cd zls
$ zig build -fsummary --verbose
error: EndOfStream

Original bug report zigtools/zls#1147

Expected Behavior

Successful build.

Activity

  1. added
    bug
    on Apr 20, 2023
  2. leecannon commented on Apr 20, 2023

    @leecannon
    ContributorAuthor

    Seems like there is a weird cache issue as well, if you use a slightly older zig (0.11.0-dev.2666+1e207f1ed) to successfully build (and generate caches) then use the broken zig (0.11.0-dev.2680+a1aa55ebe) it works but with no cache it fails.

    $ rm -rf zig-cache zig-out ~/.cache/zig
    $ zig version
    0.11.0-dev.2680+a1aa55ebe
    $ zig build
    error: EndOfStream
    $ # switch to working zig tarball
    $ zig version
    0.11.0-dev.2666+1e207f1ed
    $ zig build
    $ # switch back to broke zig tarball
    $ zig version
    0.11.0-dev.2680+a1aa55ebe
    $ zig build
    $ # same zig that gave `error: EndOfStream` above successfully compiled
    $ rm -rf zig-cache zig-out ~/.cache/zig
    $ zig build
    error: EndOfStream
    $ # but with no cache it fails again
  3. richiejp commented on Apr 21, 2023

    @richiejp

    I get a different, but possibly related error on 0.11.0-dev.2685+fac120bc3 from TLS: error: TlsInitializationFailed

    I don't have the full debugging output to hand right now. However it appears that it's trying to use an expired certificate when downloading libs from GitHub. The certificate appears to be different from the one FireFox displays.

    If you have a cache present then possibly it doesn't have to fetch the libraries. I suppose if this is the issue then providing the lib srcs by some other method might work. I'm not sure how it all works.

    EDIT: I was able to compile ZLS by serving the archives in build.zig.zon from localhost.

  4. DraagrenKirneh commented on Apr 21, 2023

    @DraagrenKirneh
    Contributor

    @richiejp The TlsInitializationFailed should be resolved now. The cause was github returning a certificate that had expired, they have fixed it now.

    It will still fail on deinit headers though.

  5. neeraj9 commented on Apr 21, 2023

    @neeraj9

    There is a different error after the certificate was resolved.

    thread 64428 panic: incorrect alignment
    D:\Work\git\ziglang\zig\lib\std\hash_map.zig:945:100: 0x7ff7643d9686 in header (zig.exe.obj)
                return @ptrCast(*Header, @ptrCast([*]Header, @alignCast(@alignOf(Header), self.metadata.?)) - 1);
                                                                                                       ^
    D:\Work\git\ziglang\zig\lib\std\hash_map.zig:959:31: 0x7ff763e3b482 in capacity (zig.exe.obj)
                return self.header().capacity;
                                  ^
    D:\Work\git\ziglang\zig\lib\std\hash_map.zig:822:50: 0x7ff763ba42b9 in next (zig.exe.obj)
                    assert(it.index <= it.hm.capacity());
                                                     ^
    D:\Work\git\ziglang\zig\lib\std\http\Headers.zig:72:23: 0x7ff76396c26d in deinit (zig.exe.obj)
            while (it.next()) |entry| {
                          ^
    D:\Work\git\ziglang\zig\lib\std\http\Client.zig:512:40: 0x7ff76396d5c7 in deinit (zig.exe.obj)
                req.response.headers.deinit();
                                           ^
    D:\Work\git\ziglang\zig\src\Package.zig:486:25: 0x7ff763969e90 in fetchAndUnpack (zig.exe.obj)
            defer req.deinit();
                            ^
    D:\Work\git\ziglang\zig\src\Package.zig:282:43: 0x7ff7639708bb in fetchAndAddDependencies (zig.exe.obj)
            const sub_pkg = try fetchAndUnpack(
                                              ^
    D:\Work\git\ziglang\zig\src\main.zig:4397:67: 0x7ff7637bf4be in cmdBuild (zig.exe.obj)
                const fetch_result = build_pkg.fetchAndAddDependencies(
                                                                      ^
    D:\Work\git\ziglang\zig\src\main.zig:298:24: 0x7ff76378c6dc in mainArgs (zig.exe.obj)
            return cmdBuild(gpa, arena, cmd_args);
                           ^
    D:\Work\git\ziglang\zig\src\main.zig:211:20: 0x7ff76378b81e in main (zig.exe.obj)
        return mainArgs(gpa, arena, args);
                       ^
    D:\Work\git\ziglang\zig\lib\std\start.zig:508:80: 0x7ff76378d651 in main (zig.exe.obj)
        return @call(.always_inline, callMainWithArgs, .{ @intCast(usize, c_argc), @ptrCast([*][*:0]u8, c_argv), envp });
                                                                                   ^
    ???:?:?: 0x7ff7655ffeb5 in ??? (zig.exe)
    ???:?:?: 0x7ff7655fff1b in ??? (zig.exe)
    ???:?:?: 0x7ff8186b269c in ??? (KERNEL32.DLL)
    ???:?:?: 0x7ff819c8a9f7 in ??? (ntdll.dll)
    
  6. added this to the 0.11.0 milestone on Apr 21, 2023
  7. added
    regression
    on Apr 21, 2023
  8. andrewrk commented on Apr 21, 2023

    @andrewrk
    Member
  9. neeraj9 commented on Apr 21, 2023

    @neeraj9

    Could this be due to memory leak identified in #15372?

  10. DraagrenKirneh commented on Apr 21, 2023

    @DraagrenKirneh
    Contributor

    It looks like this only happens when a request is redirected which happens for all github archive urls:
    https://github.com/project/repo/archive/hash.tar.gz -> https://codeload.github.com/project/repo/tar.gz/hash

  11. renerocksai commented on Apr 22, 2023

    @renerocksai

    Damn. If I change the URL in my build.zig.zon, zig build doesn't like it because the .tar.gz extension is stripped from the end of the URL

  12. nektro commented on Apr 23, 2023

    @nektro
    Contributor

    @renerocksai you should open that as an issue as well

  13. renerocksai commented on Apr 23, 2023

    @renerocksai

    @renerocksai you should open that as an issue as well

    Oh, OK, will do

  14. richiejp commented on Apr 24, 2023

    @richiejp

    There is a different error after the certificate was resolved.

    thread 64428 panic: incorrect alignment
    ... ```
    

    I guess the problem is the headers object is deinitialized 3 times. Because the Request object calls deinit on headers, but it doesn't have owenership of that object. It first gets deinitialized by fetchAndUnpack in Package.zig, then twice by Request in Client.zig due to the redirect.

    commit 1342942 seems to be the cause of that. Removing the headers deinit from lib/std/http/Client.zig:512 stops it.

    However I then also get the EndOfStream error. So we have come full circle.

  15. DraagrenKirneh commented on Apr 24, 2023

    @DraagrenKirneh
    Contributor

    However I then also get the EndOfStream error. So we have come full circle.

    The EndOfStream error is caused by the client not handling redirects correctly, it never starts a new request so the error you get is from the client trying to read the old connection which have no more data. There is a PR #15443 to fix that issue.

  16. richiejp commented on Apr 24, 2023

    @richiejp

    However I then also get the EndOfStream error. So we have come full circle.

    The EndOfStream error is caused by the client not handling redirects correctly, it never starts a new request so the error you get is from the client trying to read the old connection which have no more data. There is a PR #15443 to fix that issue.

    Yes, that works. Thanks.

  17. truemedian commented on Apr 24, 2023

    @truemedian
    Contributor

    #15416 and #15445 fixes all of the associated errors here.

  18. gwd666 commented on Jan 2, 2024

    @gwd666

    Same error when building zls from source on Ubuntu 20.04 occurs again with zig version 0.12.0-dev.1861+412999621 when behind proxy ... it worked in prior versions? wget and curl work correctly, what could be the reason for this failing with EndOfStream again? Why is there an active internet connection required anyway for building zls?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugregression

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions