From 758b893ba526890d1c311e84bddcbf732270c830 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Wed, 22 Apr 2015 15:47:14 -0400 Subject: [PATCH] try to fix the intermittent failures since #10380 I believe the bug was due to the need to hash typename->primary specially, based on how other type functions treat it. --- src/builtins.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/builtins.c b/src/builtins.c index 101597d4cefc0..71a33849d753c 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -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)); }