Skip to content

Commit

Permalink
fix heartbeat for Julia 1.9 (closes ##1062)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Dec 20, 2022
1 parent cee8285 commit 30ff84b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/heartbeat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ const zmq_proxy = Ref(C_NULL)

# entry point for new thread
function heartbeat_thread(sock::Ptr{Cvoid})
@static if VERSION v"1.9.0-DEV.1588" # julia#46609
# julia automatically "adopts" this thread because
# we entered a Julia cfunction. We then have to enable
# a GC "safe" region to prevent us from grabbing the
# GC lock with the call to zmq_proxy, which never returns.
# (see julia#47196)
ccall(:jl_gc_safe_enter, Int8, ())
end
ccall(zmq_proxy[], Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
sock, sock, C_NULL)
nothing
Expand Down

2 comments on commit 30ff84b

@maleadt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also have to leave the GC safe region after the ccall returns.

@stevengj
Copy link
Member Author

@stevengj stevengj commented on 30ff84b Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ccall never returns, which the whole point here of running it in a separate thread.

Please sign in to comment.