Stream: bugs

Topic: ✔ platform std.Thread.spawn -> unreachable -> segfault


view this post on Zulip Scott Campbell (Dec 03 2025 at 17:27):

x86_64 linux

Commit: 719fcae1151c0f1ecd30894366cbe4c9e2f99397

Adding a std.Thread.spawn call...

fn hostedStdoutLine(ops: *builtins.host_abi.RocOps, ret_ptr: *anyopaque, args_ptr: *anyopaque) callconv(.c) void {
    _ = ops;
    _ = ret_ptr;
    _ = args_ptr;

    // ...

    const thread_test = struct {
        fn worker() void {
            std.Thread.sleep(1 * std.time.ns_per_s);
        }
    };

    _ = std.Thread.spawn(.{}, thread_test.worker, .{}) catch {};

    // ...
}

Result: thread 54669 panic: reached unreachable code

[anon@nixos:~/Projects/roc]$ zig build test
[...tests fail...]

[anon@nixos:~/Projects/roc]$ ./zig-out/bin/roc ./test/fx/app.roc
thread 54669 panic: reached unreachable code
error: Child process /home/anon/.cache/roc/75fed07d9047282a9e6197f23853ba39/temp/roc-tmp-RmsPvqoZLOh3Y7e4JvbGzW1HSRiQC1uu/roc_run_3344319531 killed by signal: 11
error: Child process crashed with segmentation fault (SIGSEGV)

Then program exits, without continuing.

view this post on Zulip Anton (Dec 03 2025 at 17:42):

Hi @Scott Campbell,
Can you make a github issue for this? It may be some time before we get to it, we're currently focused on advent of code related fixes and improvements.

view this post on Zulip Scott Campbell (Dec 04 2025 at 04:11):

Done!

#8566

It's not urgent, I don't actually need threads yet.

I can probably try to make do with some kind of single threaded event loop if needed, and zig's newish IO interface, for async style concurrent code. Then it'll be easy to swap out the implementation later.

If it bothers me too much, I'll try grab a debugger and learn how to find zig segfaults...

view this post on Zulip Notification Bot (Dec 04 2025 at 04:18):

Scott Campbell has marked this topic as resolved.


Last updated: Dec 21 2025 at 12:15 UTC