这是indexloc提供的服务,不要输入任何密码
Skip to content

os2.pipe() -> Assert error #4712

@m-rei

Description

@m-rei

Context

I am calling this code from a threadpool with a size of 10, rapidly:

log.info("creating pipe")
r, w := os2.pipe() or_return
log.info("creating pipe -done")

and sometimes i get an error!
I'm trying to pipe the result of a command I'm calling back to my application and continue processing that...

the full proc looks like this:

@(private)
exec_curl :: proc(url: string) -> (output: string, err: os2.Error) {
    r, w := os2.pipe() or_return // TODO this appears to be buggy, issue: https://github.com/odin-lang/Odin/issues/4712
    defer os2.close(r)

    p: os2.Process;
    {
        defer os2.close(w)

        p = os2.process_start({
            command = {"curl", "-i", "-H \"Connection: close\"", url},
            stdout = w,
        }) or_return
    }

    out := os2.read_entire_file(r, context.allocator) or_return
    _, err = os2.process_wait(p)
    if err != nil {
        delete(out)
        return
    }
    output = string(out)

    return
}

Edit: to add a bit more context: I have a Tracking_Allocator setup and the thread pool is setup this way:

thread.pool_init(&worker_thread_pool, context.allocator, WORKER_POOL_SIZE)
defer thread.pool_destroy(&worker_thread_pool)
for &t in worker_thread_pool.threads {
	t.init_context = context
}
thread.pool_start(&worker_thread_pool)

and the connection pool this way:

    connection_thread_pool: thread.Pool
    thread.pool_init(&connection_thread_pool, context.allocator, CONNECTION_POOL_SIZE)
    defer thread.pool_destroy(&connection_thread_pool)
    for &t in connection_thread_pool.threads {
        t.init_context = context
    }
    thread.pool_start(&connection_thread_pool)

note: they all share the same context thus the same allocator.
perhaps this is relevant for tracking down the issue!

  • Operating System & Odin Version:
  • Please paste odin report output:
    Odin: dev-2025-01-nightly
    OS: Fedora Linux 41 (Forty One), Linux 6.12.6-200.fc41.x86_64
    CPU: 12th Gen Intel(R) Core(TM) i5-12400
    RAM: 31821 MiB
    Backend: LLVM 18.1.6

Expected Behavior

No assertion failure

Current Behavior

Assertion failure

Failure Information (for bugs)

/opt/odin/core/os/os2/heap_linux.odin(316:2) runtime assertion: alloc.free_idx == NOT_FREE
71888 Illegal instruction

Steps to Reproduce

  1. setup a thread pool with a size of 10
  2. create tasks (in rapid succession) which call:
  3. r, w := os2.pipe() or_return
  4. let it run for a while

Failure Logs

See screenshot for stacktrace~:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions