Skip to content

Commit c335d2e

Browse files
committed
Make threadcall gc safe
1 parent 4eb2e47 commit c335d2e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

base/threadcall.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ macro threadcall(f, rettype, argtypes, argvals...)
4343
push!(body, :(p += Core.sizeof($T)))
4444
push!(args, arg)
4545
end
46+
push!(body, :(gc_state = ccall(:jl_gc_safe_enter, Int8, (), )))
4647
push!(body, :(ret = ccall(fptr, $rettype, ($(argtypes...),), $(args...))))
4748
push!(body, :(unsafe_store!(convert(Ptr{$rettype}, retval_ptr), ret)))
49+
push!(body, :(gc_state = ccall(:jl_gc_safe_leave, Cvoid, (Int8,), gc_state)))
4850
push!(body, :(return Int(Core.sizeof($rettype))))
4951

5052
# return code to generate wrapper function and send work request thread queue

0 commit comments

Comments
 (0)