Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os2.pipe() -> Assert error #4712

Open
Tracked by #4710
m-rei opened this issue Jan 17, 2025 · 2 comments
Open
Tracked by #4710

os2.pipe() -> Assert error #4712

m-rei opened this issue Jan 17, 2025 · 2 comments

Comments

@m-rei
Copy link

m-rei commented Jan 17, 2025

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

@laytan laytan mentioned this issue Jan 17, 2025
57 tasks
@laytan
Copy link
Collaborator

laytan commented Jan 18, 2025

Looks like an issue in the thread safety of the allocator, @jasonKercher are you able to have a look at this?

@jasonKercher
Copy link
Contributor

I can take a look at it tomorrow. However, I think it might be best to just drop that allocator in favor of malloc for now until there is a general purpose allocator in base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants