Julia: Libuv and tasks are not thread safe

Created on 28 Dec 2015  路  11Comments  路  Source: JuliaLang/julia

Doing
@threads for i = 1:10 sleep(2) end
regularly segfaults.

This is the backtrace. I understand that sleep() doesn't apply to threads and applies to tasks, but I just thought I'd post this here:

#0  0x00007ffff6e248c9 in jl_apply (nargs=0, args=0x0, f=0x0) at /home/ranjan/julia-threading5/src/julia.h:1375
#1  start_task () at /home/ranjan/julia-threading5/src/task.c:246
#2  0x0000000000000000 in ?? ()
O multithreading

Most helpful comment

Fixed by #32174 and #32309.

All 11 comments

Right. Task switches and IO's are the only two segfaults left with threading that I've reproduced.

You can use Libc.systemsleep(2) for a blocking pause. sleep also tries to access/modify libuv state, which is not threadsafe.

Is this a Julia 0.6 issue? Or Julia 1.0?

It will not block 0.6

There's two issues here. This first is a fully thread-safe multi-threaded I/O system which is a big issue. The second is just the original report that sleep doesn't work right, which is related, but could probably be fixed differently (e.g. if on a thread sleep does systemsleep). Which one were you asking about?

Thanks for the responses. I was wondering about the former--thread-safe IO in general. Seems like this issue has become a catch-all for libuv+threading issues, with others closed as duplicates.

just tested in Julia 1.0.2, still have the segfault error.

This is not expected to work until PARTR multi-threading is officially announced as available.

Specifically, this issue will be closed when https://github.com/JuliaLang/julia/pull/29706 is merged.

@JeffBezanson: close this now?

Fixed by #32174 and #32309.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

omus picture omus  路  3Comments

musm picture musm  路  3Comments

iamed2 picture iamed2  路  3Comments

manor picture manor  路  3Comments

wilburtownsend picture wilburtownsend  路  3Comments