Skip to content
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "6f1fad26-d15e-5dc8-ae53-837a1d7b8c9f"
license = "MIT"
desc = "C shim for task copying in Turing"
repo = "https://github.com/TuringLang/Libtask.jl.git"
version = "0.5.1"
version = "0.5.2"

[deps]
Libtask_jll = "3ae2931a-708c-5973-9c38-ccf7496fb450"
Expand Down
9 changes: 7 additions & 2 deletions src/ctask.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ struct CTask
task::Task

function CTask(task::Task)
new(enable_stack_copying(task))
ret = new(enable_stack_copying(task))
task.storage === nothing && (task.storage = IdDict())
task.storage[:ctask] = ret
ret
end
end

Expand All @@ -24,12 +27,13 @@ end

function Base.showerror(io::IO, ex::CTaskException)
println(io, "CTaskException:")
ct = ex.task
bt = @static if VERSION < v"1.6.0-DEV.1145"
ct.backtrace
else
ct.storage[:_libtask_bt]
end
showerror(io, ex.task.exception, bt)
showerror(io, ct.exception, bt)
end

# Utility function for self-copying mechanism
Expand Down Expand Up @@ -107,6 +111,7 @@ function Base.copy(ctask::CTask)
setstate!(newtask, getstate(task))
newtask.result = task.result

copy_tarrays(task, newtask)
return CTask(newtask)
end

Expand Down
Loading