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

trying to support stage2 compiler #1

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

endel
Copy link

@endel endel commented Aug 30, 2022

Hi @Luukdegram, thanks for your efforts on this lib, I'm currently researching and trying to understand TLS1.3/QUIC and this is being really helpful resource to me!

I'm trying to support the stage2 compiler for your lib here, would appreciate it if you can give me any direction I could take to fix these compilation errors:

feilich/src/tls.zig:617:23: error: values of type 'fn(*tls.Curve, [32]u8, *[32]u8) error{IdentityElement}!void' must be comptime known, but operand value is runtime known
        try self.genFn.*(self, private_key, public_key_out);
            ~~~~~~~~~~^~
feilich/src/tls.zig:617:23: note: use '*const fn(*tls.Curve, [32]u8, *[32]u8) error{IdentityElement}!void' for a function pointer type
feilich/src/cert/asn1.zig:194:44: error: values of type 'fn(*cert.asn1.Decoder, u8) error{ContextSpecific,EndOfData,InvalidLength,InvalidTag,OutOfMemory}!cert.asn1.Value' must be comptime known, but operand value is runtime known
                            return callback.*(self, @truncate(u3, tag_byte));
                                   ~~~~~~~~^~
feilich/src/cert/asn1.zig:194:44: note: use '*const fn(*cert.asn1.Decoder, u8) error{ContextSpecific,EndOfData,InvalidLength,InvalidTag,OutOfMemory}!cert.asn1.Value' for a function pointer type
error: test...
error: The following command exited with error code 1:

If I use main_tests.use_stage1 = true; config on build.zig all tests are passing.

Thank you!

@endel
Copy link
Author

endel commented Aug 30, 2022

Update: managed to get past the compilation error (d67b815), now the test suite is panicking here 👀:

Test [21/29] test.Object identifier... thread 984457 panic: access of inactive union field
feilich/src/cert/asn1.zig:330:9: 0x104f45f0b in decodeObjectIdentifier (test)
        identifier.object_identifier.data[0] = initial_byte / 40;
        ^
feilich/src/cert/asn1.zig:219:66: 0x104f27cc3 in decodeMaybeTag (test)
            .object_identifier => try self.decodeObjectIdentifier(),
                                                                 ^
feilich/src/cert/asn1.zig:169:35: 0x104f0d6ff in decode (test)
        return self.decodeMaybeTag(null);
                                  ^
feilich/src/cert/asn1.zig:405:37: 0x104f0e4cf in test.Object identifier (test)
    const value = try decoder.decode();
                                    ^
zig-dev/lib/zig/test_runner.zig:79:28: 0x104e722d7 in main (test)
        } else test_fn.func();
                           ^
zig-dev/lib/zig/std/start.zig:564:22: 0x104e73cab in main (test)
        },
                     ^
???:?:?: 0x18de1142f in ??? (???)
???:?:?: 0x0 in ??? (???)

@Luukdegram
Copy link
Owner

There was a bug in @unionInit that was fixed last night. It may be worth trying it again with the latest Zig master (you'll have to compile it yourself).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants