-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix tracking of serialization state for Function types and Expr #13134
Conversation
deserialize_cycle(s, f) | ||
f.env = deserialize(s) |
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 think this needs to be after deserialize_cycle
to handle possible cycles through f.env
.
Thanks, great catch. |
c450f8c
to
44f1c17
Compare
This could really use a test if at all possible. |
end | ||
linfo = deserialize(s) | ||
f = ccall(:jl_new_closure, Any, (Ptr{Void}, Ptr{Void}, Any), C_NULL, C_NULL, linfo)::Function | ||
|
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.
whitespace
Adding tests was a good suggestion. Threw up errors that @JeffBezanson / others are probably in a better position to fix. |
why ci skip, are they still broken? |
@test b[10]("foobar") == "foobar" | ||
|
||
@test b[end] == 5 | ||
@test length(b) == length(A) |
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.
As the patch stands, deserialized A
is
1 ====> 1
2 ====> 2
3 ====> Any[1,2,#= circular reference =#,abs,abs,(anonymous function),AST(:($(Expr(:lambda, Any[:(x::Any)], Any[Any[Any[:x,:Any,0]],Any[],0,Any[]], :(begin # none, line 1:
return x
end))))),echo,:(begin # none, line 1:
return x
end),CycleFoo.echo,:(return x),4,5]
4 ====> abs
5 ====> abs
6 ====> (anonymous function)
7 ====> AST(:($(Expr(:lambda, Any[:(x::Any)], Any[Any[Any[:x,:Any,0]],Any[],0,Any[]], :(begin # none, line 1:
return x
end)))))
8 ====> echo
9 ====> begin # none, line 1:
return x
end
10 ====> CycleFoo.echo
11 ====> return x
12 ====> 4
13 ====> 5
indexexes 6,7 should be the same. As also index pairs (8,9) and (10,11)
Yup. The fix may be a little more involved. |
elseif b==3 | ||
env = deserialize(s) | ||
return ccall(:jl_new_gf_internal, Any, (Any,), env)::Function | ||
f = ccall(:jl_new_gf_internal, Any, (Any,), env)::Function |
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.
Can anyone give an example of this type of function? Needs to be added to the tests.
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 believe it is for inner generic functions. You can also generate a function that references itself using
function foo()
f = x->f(x)
end
A short term workaround could be to remove cyclic handling for Function types. |
Ok I think I have this working now. Will push to this branch. |
30e856c
to
a9ae0ad
Compare
fix tracking of serialization state for Function types and Expr
backported in #13182 |
While
serialize_cycle
was being called for allFunction
types,deserialize_cycle
was not. This causes a mismatch in deserializing state.Closes #12848
@JeffBezanson - I am not really familiar with the ser/deser codebase. Can you review this?