-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing aliasing detection/handling #46
Comments
Thanks @martinholters for reaching out about this, the context, & the potential fix. Must admit I am not really familiar with |
Any news? |
Hi Martin Thanks for the reminder! Sorry but I have not gotten around to this yet. It's crazy how fast one month evaporates these days! The new academic semester kicking in at MIT also did seriously stress my organization. Am putting this in my calendar for next week in case I don't get to it this week ... |
Indeed it is... |
Not sure I understand all of the subtleties in this but I think #54 implements one of the fixes you had suggested. I almost added the Would you advise that I add the ps. sorry for the lag. I see that JuliaLang/julia#26237 is still open so maybe I am not too late |
I think the change to |
Disclaimer: My interest in this has only been triggered by MeshArrays showing up as one of the packages that would be broken by JuliaLang/julia#26237. I have not used MeshArrays myself for anything and don't know my way around the package.
Given
we get
although clearly,
A
andB
do alias as they share the same underlying data. This can result in dot-assigns failing to unalias their arguments, as in:This fix would consist in implementing
Base.dataids(::gcmarray)
such thatdataids(A)
anddataids(B)
share at least one common entry.Now the change to the fallback
dataids
in JuliaLang/julia#26237 effectively definesAnd with that:
Hooray! But...
and this is the problem detected in JuliaLang/julia#26237.
What happens is the following: upon detection of the aliasing, the broadcast machinery calls
unaliascopy
, which falls back tocopy
, which falls back tocopymutable
, which falls back tocopyto!(similar(A), A)
. ButThis in turn makes
copyto!
callunaliascopy
(viaunalias
) again, resulting in the stack overflow.There are a few relatively simple options to break this vicious circle, I'm just not sure which is the right one. The first question to answer is: What should be inside the
dataids
? I think the rule of thumb is that ifsetindex!(a, ...)
can alter the result ofgetindex(b, ...)
, thendataids(a)
anddataids(b)
should share at least one common entry.setindex!(A::gcmarray, ...)
only changesA.f
, butgetindex(A::gcmarray, ...)
also accessesA.fIndex
andA.fSize
, so I think the extendeddataids
from above is ok, but correct me if I'm wrong. Then eithersimilar(::gcmarray)
should be adjusted to also make copies offIndex
andfSize
orunaliascopy
orcopy
should be specilaized; I don't know which is best here. But e.g.would fix the problem.
The text was updated successfully, but these errors were encountered: