#http client stucks in release mode

1 messages · Page 1 of 1 (latest)

proud ether
#

I have this simple snippet

   std.log.info("starting", .{});

    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    defer _ = gpa.deinit();

    const allocator = gpa.allocator();

    var client = std.http.Client{
        .allocator = allocator,
    };
    defer client.deinit();

    std.log.info("starting 2", .{});

    const uri = try std.Uri.parse("https://ziglang.org/download/index.json");
    var headers = std.http.Headers.init(allocator);
    defer headers.deinit();

    var req = try client.request(std.http.Method.GET, uri, headers, .{});
    defer req.deinit();

    std.log.info("starting 3", .{});

It works when building in debug mode, but crashing when running it in any Release mode.

sacred anvil
proud ether
#

It doesn't print the starting 3

sacred anvil
#

What happens if you run it in a debugger?

#

Also what OS are you on, and how are you building/running this code?

#

It would also be good if you could send the full file, just in case there's something you're doing around this code that's breaking stuff

#

Oh, and also use std.debug.print not std.log.info so that the differing default log levels between release and debug don't affect it

sacred anvil
#

It's best to not use std.log for testing or temporary debug messages, for this reason

proud ether
#

nothing fancy

#

also i put the std.log.info to see where the crashes happens

#

im on windows and i see a lot of error [0xC000_0005 which should be an invalid access memory] into the event viewer

sacred anvil
#

so you can actually see it, regardless of log level

proud ether
#

I added the log after the crash just to figure out what's going. Im going to remove them, but this is not gonna resolve the main issue I guess [?]

sacred anvil
#

If you're able to run the code in a debugger that would help

#

That way you can step through and see where it actually crashes

proud ether
#

sure

#

lemme setup a quick vscode json

#

that's interesting

sacred anvil
#

go up in the backtrace, you wanna find where that segfault actually occurs

proud ether
#

yeah it's full of log of the same entry

sacred anvil
#

Okay, if looking at the backtrace doesn't work then step forward until you hit the exception

proud ether
#

yeah done, looks like an issue with tls

sacred anvil
#

I'd be surprised

#

Don't think http.Client uses any tls

#

or wait, maybe I got the wrong acronym for tls lol

#

do you mean thread local storage or transport layer security?

proud ether
#

the transport layer sec

sacred anvil
#

oh, interesting

proud ether
sacred anvil
#

so it's segfaulting in memset? hmmm

proud ether
#

the code is inlined so hard to debug the last lines

#

here is where it stops

#

i think it got it: here crashes

proud ether
#

probably better to open an issue on gh

thin cloak
#

and just looking through the code it shouldn't be able to

proud ether
thin cloak
#

yes

proud ether
#

and i assume zig master version right?

thin cloak
#

0.12.0-286

proud ether
#

So most probably the issue is on my side. Usually these kind of things happen when one compiler messes with others

#

But from what i know zig is standalone

thin cloak
#

zig is standalone and self contained

#

if you run the snippet in the issue does it segfault?

proud ether
#

yeah

#

but i got it

#

there is some issue with the zip library i linked

#

removing the zip lib it works