-
Notifications
You must be signed in to change notification settings - Fork 56
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
eval julia_type input in Main instead of current_module() #101
Conversation
Did it pass the tests locally? It didn't with CI. |
…ent_module(), since input types might not exist in current_module()
I just modified this PR to make Is there a way to perform this check ahead of time instead of using I suppose I could drill down through any namespaces given in |
Might JuliaCI/BenchmarkTools.jl#23 also be worked around with |
Oh, wait, I see that it's an import-cycle-thing. Gack. I suppose we can have this. I'll wait to hit merge until you decide how hard you want to work to avoid the use of |
I'm not sure if I'll have time to look at this more closely, but this should probably not have been using |
Yup, this is exactly the bug I opened this PR to work around. I originally removed It seems like it's not worth it for me to refactor the |
Doesn't seem like there's any dissent here, good to merge? |
Bump, this is the only thing preventing getting picosecond benchmark resolution on Nanosoldier. |
Thanks! |
Can we tag a new version of JLD that incorporates this PR (so that JuliaCI/BenchmarkTools.jl#27 will be mergable)? Thanks again! |
try | ||
# It's possible that `e` will represent a type not present in current_module(), | ||
# but as long as `e` is fully qualified, it should exist/be reachable from Main | ||
typ = eval(Main, e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should really use getfield, eval'ing code that may come from a binary file without the user seeing it is a bad idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but it's highly non-trivial since types can have type parameters. The is_valid_type_ex
function tries to ensure that eval
ing the type expression will not have side effects, and is pretty conservative, which is bad because it means that arbitrary immutables cannot be used as type parameters (JuliaIO/HDF5.jl#204). The real solution is to encode the types in a way that we don't need to use eval
to reconstruct them. JLD2 will do this, but it is not so easy to slap onto JLD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also note that this behavior has existed for years and did not change with this PR)
...since input types might not exist in
current_module()
. This fixes using a function which callsJLD.translate
inside a module scope whereJLD
is not imported (but the caller does haveJLD
imported). This bug can be seen in theSerializationTests
failure here.I'm not sure whether this PR is really the correct fix for this issue - it might violate existing assumptions or rely on bad assumptions. For example, this fix may be broken if
e
is not fully qualified.Credit to @maleadt for hunting this down.