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

Creating non-sticky tasks in a @threads loop causes "Unlocking a lock in a different thread" #31614

Closed
vchuravy opened this issue Apr 4, 2019 · 0 comments · Fixed by #31619
Closed
Labels
multithreading Base.Threads and related functionality

Comments

@vchuravy
Copy link
Member

vchuravy commented Apr 4, 2019

After fixing #31613 my mean test-code (enquing work from tid==1 and then servicing it else on the other worker threads), fails with a julia/src/locks.h:152: jl_mutex_unlock_nogc: Assertion lock->owner == jl_thread_self() && "Unlocking a lock in a different thread."'

chaos.jl

 Base.Threads.@threads for i in 1:Base.Threads.nthreads()
           if Base.Threads.threadid() == 1
             tasks = Task[]
             for i in 1:10
               t = Task(()->println("tid: ", Base.Threads.threadid()))
               t.sticky = false
               push!(tasks, t)
               schedule(t)
             end
             Base.sync_end(tasks)
           end
        end

To cite Jeff: The only parallel program one would ever want to execute is to print the threadid.

➜  julia ./julia chaos.jl
tid: 1julia: /home/vchuravy/src/julia/src/locks.h:152: jl_mutex_unlock_nogc: Assertion `lock->owner == jl_thread_self() && "Unlocking a lock in a different thread."' failed.

signal (6): Aborted
in expression starting at /home/vchuravy/builds/julia/chaos.jl:1
gsignal at /usr/lib/libc.so.6 (unknown line)
abort at /usr/lib/libc.so.6 (unknown line)
__assert_fail_base.cold.0 at /usr/lib/libc.so.6 (unknown line)
__assert_fail at /usr/lib/libc.so.6 (unknown line)
jl_mutex_unlock_nogc at /home/vchuravy/src/julia/src/locks.h:151 [inlined]
jl_eh_restore_state at /home/vchuravy/src/julia/src/rtutils.c:257
uv_write at ./stream.jl:875
unsafe_write at ./stream.jl:923
macro expansion at ./gcutils.jl:87 [inlined]
write at ./strings/io.jl:177 [inlined]
show at ./show.jl:586 [inlined]
print at ./strings/io.jl:37
unknown function (ip: 0x7f1074afa367)
jl_apply_generic at /home/vchuravy/src/julia/src/gf.c:2197
print at ./strings/io.jl:48
jl_apply_generic at /home/vchuravy/src/julia/src/gf.c:2197
jl_apply at /home/vchuravy/src/julia/src/julia.h:1604 [inlined]
jl_f__apply at /home/vchuravy/src/julia/src/builtins.c:563
println at ./strings/io.jl:75
jl_apply_generic at /home/vchuravy/src/julia/src/gf.c:2197
println at ./coreio.jl:4
unknown function (ip: 0x7f1074af9997)
jl_apply_generic at /home/vchuravy/src/julia/src/gf.c:2197
#3 at /home/vchuravy/builds/julia/chaos.jl:5
jl_apply_generic at /home/vchuravy/src/julia/src/gf.c:2197
jl_apply at /home/vchuravy/src/julia/src/julia.h:1604 [inlined]
start_task at /home/vchuravy/src/julia/src/task.c:583
unknown function (ip: 0xffffffffffffffff)
Allocations: 177483 (Pool: 177412; Big: 71); GC: 0
fish: “./julia chaos.jl” terminated by signal SIGABRT (Abort)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multithreading Base.Threads and related functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant