You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is one way to at least warn users that code like the code shown in #132 is incorrect. The idea would be that when a user calls
tmap(f, itr)
(or tmapreduce or whatever), we want to check if any of the fields of f are a Core.Box, which would signal that the user accidentally has caused a concurrency violation.
Here's a fun example:
julia>let
A =1
res1 =tmap(1:10) do i
A = i
sleep(rand())
A
end
res2 =tmap(1:10) do i
local A = i
sleep(rand())
A
end@info"Oops!" res1' res2'end
┌ Info: Oops!
│ res1'=
│ 1×10adjoint(::Vector{Int64}) with eltype Int64:
│ 821084268104
│ res2'=
│ 1×10adjoint(::Vector{Int64}) with eltype Int64:
└ 12345678910
The problem is that the A=1 inside the let block is making it so that inside the tmap for res1, A actually is a Core.Box and every time we assign to A, we are mutating the Core.Box as a race condition, and each time we reference A, we're making a racey read.
The Core.Box design for closures is fine for sequential programs, but is wildly incorrect for concurrenct programs. This should actually be pretty easy to detect and throw an informative error.
I don't think there is any valid use-case where you'd put a boxed closure into one of our threaded functions and not cause a data-race.
The text was updated successfully, but these errors were encountered:
This is one way to at least warn users that code like the code shown in #132 is incorrect. The idea would be that when a user calls
tmap(f, itr)
(or
tmapreduce
or whatever), we want to check if any of the fields off
are aCore.Box
, which would signal that the user accidentally has caused a concurrency violation.Here's a fun example:
The problem is that the
A=1
inside the let block is making it so that inside thetmap
forres1
,A
actually is aCore.Box
and every time we assign toA
, we are mutating theCore.Box
as a race condition, and each time we referenceA
, we're making a racey read.The
Core.Box
design for closures is fine for sequential programs, but is wildly incorrect for concurrenct programs. This should actually be pretty easy to detect and throw an informative error.I don't think there is any valid use-case where you'd put a boxed closure into one of our threaded functions and not cause a data-race.
The text was updated successfully, but these errors were encountered: