-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed as not planned
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior
Description
Zig Version
0.12.0-dev.2236+32e88251e
Steps to Reproduce and Observed Behavior
The MWE deterministicaly triggers a TLS handshake failure, which is expected, but the trace back has unnecessary entries.
const std = @import("std");
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
var client = std.http.Client{ .allocator = allocator };
defer client.deinit();
try client.loadDefaultProxies();
const url = "https://bing.com";
const uri = try std.Uri.parse(url);
var headers = std.http.Headers{ .allocator = allocator };
defer headers.deinit();
var req = try client.open(.GET, uri, headers, .{ .max_redirects = 10 });
defer req.deinit();
try req.send(.{});
try req.wait();
const body = try req.reader().readAllAlloc(allocator, 16 * 1024 * 1024);
defer allocator.free(body);
std.debug.print("{s}: {s}\n", .{ url, body });
}When run with zig run traceback-issue.zig, the log is:
error: TlsInitializationFailed
/home/mlinux/Code/install/lib/zig/std/crypto/Certificate.zig:689:40: 0x12fcbb9 in parseEnum__anon_56046 (traceback-issue)
return E.map.get(oid_bytes) orelse return error.CertificateHasUnrecognizedObjectId;
^
/home/mlinux/Code/install/lib/zig/std/crypto/Certificate.zig:680:5: 0x1271dab in parseExtensionId (traceback-issue)
return parseEnum(ExtensionId, bytes, element);
^
/home/mlinux/Code/install/lib/zig/std/os.zig:766:27: 0x11146ce in read (traceback-issue)
.CONNRESET => return error.ConnectionResetByPeer,
^
------- Above is the true cause of error if you step through it -------
...[snip]...
/home/mlinux/Code/zig/traceback-issue.zig:18:15: 0x10a09f4 in main (traceback-issue)
var req = try client.open(.GET, uri, headers, .{ .max_redirects = 10 });
^
Note that the code already errors upon reaching .CONNRESET => return error.ConnectionResetByPeer, but the top two trace back entries report spurious problem with parseEnum, which is unexpected.
Expected Behavior
The top two entries should not appear, i.e., the trace back starts from the line .CONNRESET => return error.ConnectionResetByPeer.
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior