Skip to content

Segmentation fault in scheduler.run(.wait) #98

@edman

Description

@edman

Hello 👋

I'm getting a segmentation fault in `scheduler.run(.wait).

Here's the stacktrace:

Segmentation fault at address 0x7f1d0fc5fe20
.../.cache/zig/p/aio-0.0.0-776t3qVVBQCS5e6tiQ2qs6ds8N3NaEvbxqLg6womBPI_/src/coro/Scheduler.zig:85:24: 0x11f067f in tick (zigproject)
            next = node.next;
                       ^
.../.cache/zig/p/aio-0.0.0-776t3qVVBQCS5e6tiQ2qs6ds8N3NaEvbxqLg6womBPI_/src/coro/Scheduler.zig:111:30: 0x11e52b1 in run (zigproject)
            if (try self.tick(.blocking) == 0) break;
                             ^
.../zigproject/src/main.zig:282:22: 0x11e4a02 in main (zigproject)
    try scheduler.run(.wait);
                     ^
/nix/store/hmipmal12akswjhv9wmlkk13hsm3nf7w-zig-0.14.0/lib/zig/std/start.zig:656:37: 0x11cf5ea in posixCallMainAndExit (zigproject)
            const result = root.main() catch |err| {
                                    ^
/nix/store/hmipmal12akswjhv9wmlkk13hsm3nf7w-zig-0.14.0/lib/zig/std/start.zig:271:5: 0x11cf19d in _start (zigproject)
    asm volatile (switch (native_arch) {
    ^
???:?:?: 0x0 in ??? (???)

It looks like it's running the POSIX backend (if it matters):

warning(aio_io_uring): unsupported OP: BIND
warning(aio_linux): io_uring unsupported, using the posix backend

Could it be this is caused by nested waits in the same scheduler? I think that's when the problem started to happen.

In my code I scheduler.spawn a task and then scheduler.run(.wait) for it. That task takes the scheduler as an argument and spawns new subtasks internally, then waits for them one by one with subtask.complete(.wait) to produce a final result.

Once all subtasks end, the original task ends, and that's when the segfault happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions