Skip to content

Commit

Permalink
try to fix the intermittent failures since #10380
Browse files Browse the repository at this point in the history
I believe the bug was due to the need to hash typename->primary
specially, based on how other type functions treat it.
  • Loading branch information
JeffBezanson committed Apr 22, 2015
1 parent b4c9198 commit 7ec501d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,12 @@ DLLEXPORT uptrint_t jl_object_id(jl_value_t *v)
if (dt == jl_datatype_type) {
jl_datatype_t *dtv = (jl_datatype_t*)v;
uptrint_t h = 0xda1ada1a;
// has_typevars always returns 0 on name->primary, so that type
// can exist in the cache. however, interpreter.c mutates its
// typevars' `bound` fields to 0, corrupting the cache. this is
// avoided simply by hashing name->primary specially here.
if (dtv->name->primary == v)
return bitmix(bitmix(h, dtv->name->uid), 0xaa5566aa);
return bitmix(bitmix(h, dtv->name->uid),
jl_object_id((jl_value_t*)dtv->parameters));
}
Expand Down

1 comment on commit 7ec501d

@vtjnash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this breaks an assumption made by the deserializer that jl_object_id won't access the jl_datatype_t->name field, since rebuilding an ObjectIdDict may see a partially constructed type. for some reason, this seems to come up particularly often on my PR branch:

https://travis-ci.org/JuliaLang/julia/builds/62794883
https://ci.appveyor.com/project/StefanKarpinski/julia/build/1.0.4753
https://travis-ci.org/JuliaLang/julia/builds/62794891

what's your preference on how to fix this? there seem to be 9 usages of ObjectIdDict in base (2 in serializer, an empty one in multi.jl, another empty one in inference.jl, an empty one in stream.jl, an empty one in socket.jl, a small one in replutil.jl, and presumably the rest are caused by docs.jl)

Please sign in to comment.