Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Spawn passes refs across threads #7057
import threadpool type Foo = ref object proc echoFooAddr(f: Foo) = echo cast[int](f) proc test(i: Foo) = var p = proc() = echoFooAddr(i) p() # Print i addr on the main thread spawn p() # print i addr on the secondary thread sync() var i: Foo i.new() test(i)
Outputs two identical numbers. In real life results in random gc crashes.
Expected behavior: closure context should be deep-copied, so that secondary thread prints different address.