Skip to content

x86_64 backend cant make HTTPS requests #18126

@Beyley

Description

@Beyley

Zig Version

0.12.0-dev.1726+8b1097083

Steps to Reproduce and Observed Behavior

Clone this repo at commit 2900ecbcf8ca3b6e6827c0a82164f22c33668e89
Compile with zig build -Duse_llvm=false run on a Linux host, with a file located at ~/.config/fresh_presence_config.ini with the contents

instance_url = https://lbp.littlebigrefresh.com/
username = Beyley
close_upon_game_exit = false

App crashes on startup when it attempts to ask the server for instance information

steps [2/6] zig build-exe FreshPresence Debug native... Semantic Analysis [5081] ... info: Reading config from /home/beyley/.config/fresh_presence_config.ini
General protection exception (no address available)
/usr/lib/zig/lib/std/crypto/tls/Client.zig:1286:5: 0x8277b1d in prepareCiphertextRecord (main.zig)
    return switch (native_endian) {
    ^
Unwind error at address `:0x8277b1d` (error.AddressOutOfRange), trace may be incomplete

/usr/lib/zig/lib/std/crypto/tls/Client.zig:740:43: 0x80ded03 in writeEnd__anon_14231 (main.zig)
    var prepared = prepareCiphertextRecord(c, &iovecs_buf, &ciphertext_buf, bytes, .application_data);
                                          ^
/usr/lib/zig/lib/std/crypto/tls/Client.zig:710:20: 0x827f9b3 in write__anon_15793 (main.zig)
    return writeEnd(c, stream, bytes, false);
                   ^
/usr/lib/zig/lib/std/crypto/tls/Client.zig:717:29: 0x827fb18 in writeAll__anon_15792 (main.zig)
        index += try c.write(stream, bytes[index..]);
                            ^
/usr/lib/zig/lib/std/http/Client.zig:302:40: 0x827fcbe in writeAllDirectTls (main.zig)
        return conn.tls_client.writeAll(conn.stream, buffer) catch |err| switch (err) {
                                       ^
/usr/lib/zig/lib/std/http/Client.zig:312:42: 0x80e2b0a in writeAllDirect (main.zig)
            return conn.writeAllDirectTls(buffer);
                                         ^
/usr/lib/zig/lib/std/http/Client.zig:340:32: 0x80b0915 in flush (main.zig)
        try conn.writeAllDirect(conn.write_buf[0..conn.write_end]);
                               ^
/usr/lib/zig/lib/std/http/Client.zig:730:35: 0x8083013 in send (main.zig)
        try req.connection.?.flush();
                                  ^
/home/beyley/.cache/zig/p/1220e05e6e1d110e9b2e4511358e621a2b9e7b86e8f33bd7201d21e30f1992073bc4/src/api.zig:307:21: 0x802ccf9 in makeRequest__anon_10053 (main.zig)
    try request.send(.{});
                    ^
/home/beyley/.cache/zig/p/1220e05e6e1d110e9b2e4511358e621a2b9e7b86e8f33bd7201d21e30f1992073bc4/src/api.zig:393:34: 0x8016fd7 in getInstanceInformation (main.zig)
    var request = try makeRequest(
                                 ^
/home/beyley/Projects/PROGRAMMING/Zig/FreshPresence/src/main.zig:76:64: 0x80079b8 in runApp (main.zig)
    var instance_info_response = try Api.getInstanceInformation(allocator, uri);
                                                               ^
/home/beyley/Projects/PROGRAMMING/Zig/FreshPresence/src/main.zig:43:11: 0x800ec06 in main (main.zig)
    runApp(allocator) catch |err| {
          ^
/usr/lib/zig/lib/std/start.zig:585:37: 0x800f39a in main (main.zig)
            const result = root.main() catch |err| {
                                    ^

Expected Behavior

App runs as it does on the LLVM backend, with the logs of

┌─[beyley@arch] - [~/Projects/PROGRAMMING/Zig/FreshPresence] - [2023-11-25 06:08:37]
└─[1] <git:(master 2900ecb) > zig build run
info: Reading config from /home/beyley/.config/fresh_presence_config.ini
info: Connected to instance LittleBigRefresh
info: Found user Beyley with id 64d761a52878d52b63a53ae0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions