lightpanda-io / browser

The open-source browser made for headless usage
https://lightpanda.io
GNU Affero General Public License v3.0
117 stars 0 forks source link

illegal instruction address on linux with nightly build when using TLS #256

Closed krichprollsch closed 2 months ago

krichprollsch commented 2 months ago

Using the nightly build, we get an illegal instruction error when requesting a website using TLS on linux.

$ ~/Downloads/lightpanda-get-x86_64-linux https://example.com
debug(browser): starting GET https://example.com
Illegal instruction at address 0x163f8a6
/opt/hostedtoolcache/zig/0.12.1/x64/lib/std/crypto/sha2.zig:260:56: 0x163f8a6 in round (browsercore-get)
/opt/hostedtoolcache/zig/0.12.1/x64/lib/std/crypto/sha2.zig:129:24: 0x1596b23 in update (browsercore-get)
/opt/hostedtoolcache/zig/0.12.1/x64/lib/std/crypto/hmac.zig:58:28: 0x163fc6e in create (browsercore-get)
/opt/hostedtoolcache/zig/0.12.1/x64/lib/std/crypto/ecdsa.zig:358:23: 0x1592fd6 in create (browsercore-get)
/opt/hostedtoolcache/zig/0.12.1/x64/lib/std/crypto/tls/Client.zig:157:74: 0x1563911 in init__anon_21814 (browsercore-get)
/opt/hostedtoolcache/zig/0.12.1/x64/lib/std/http/Client.zig:1357:60: 0x153e45a in connectTcp (browsercore-get)
/opt/hostedtoolcache/zig/0.12.1/x64/lib/std/http/Client.zig:1492:38: 0x1536ebc in connect (browsercore-get)
/opt/hostedtoolcache/zig/0.12.1/x64/lib/std/http/Client.zig:1640:27: 0x150ae5c in open (browsercore-get)
/home/runner/work/browser/browser/src/browser/loader.zig:61:42: 0x150a30a in get (browsercore-get)
/home/runner/work/browser/browser/src/browser/browser.zig:241:47: 0x1520986 in main (browsercore-get)
/opt/hostedtoolcache/zig/0.12.1/x64/lib/std/start.zig:511:37: 0x1522a7f in main (browsercore-get)
../sysdeps/nptl/libc_start_call_main.h:58:16: 0x7f513dba5c89 in __libc_start_call_main (../sysdeps/x86/libc-start.c)
../csu/libc-start.c:360:3: 0x7f513dba5d44 in __libc_start_main_impl (../sysdeps/x86/libc-start.c)
???:?:?: 0x150a024 in ??? (???)
???:?:?: 0x0 in ??? (???)
Aborted
krichprollsch commented 2 months ago

It seems the GH CPU we use to compile the project supports sha instruction, the code passes this check https://github.com/ziglang/zig/blob/master/lib/std/crypto/sha2.zig#L241 but my own CPU doesn't.

const std = @import("std");
const builtin = @import("builtin");

pub fn main() !void {
    if (std.Target.x86.featureSetHas(builtin.cpu.features, .sha)) {
        std.debug.print("sha\n", .{});
    }
    if (std.Target.x86.featureSetHas(builtin.cpu.features, .avx2)) {
        std.debug.print("avx\n", .{});
    }
}

The result on my computer is:

$ zig run main.zig 
avx