From e53719904ccf2c3d99331b060c29b85a42ce7f30 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 12 Feb 2019 15:46:49 -0500 Subject: [PATCH] fix #29936, precompile should not assume UnionAlls have stable addresses (#31047) (cherry picked from commit 2dd48b96b17bf57c33c2f83c7d91e31690410227) --- src/dump.c | 4 ++-- test/precompile.jl | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/dump.c b/src/dump.c index d29ae8565bdde..9f379e3f0e439 100644 --- a/src/dump.c +++ b/src/dump.c @@ -257,7 +257,7 @@ static int type_parameter_recursively_external(jl_value_t *p0) JL_NOTSAFEPOINT return 0; if (module_in_worklist(p->name->module)) return 0; - if (p->name->wrapper != (jl_value_t*)p0) { + if (jl_unwrap_unionall(p->name->wrapper) != (jl_value_t*)p) { if (!type_recursively_external(p)) return 0; } @@ -745,7 +745,7 @@ static void jl_serialize_value_(jl_serializer_state *s, jl_value_t *v, int as_li else if (jl_is_unionall(v)) { write_uint8(s->s, TAG_UNIONALL); jl_datatype_t *d = (jl_datatype_t*)jl_unwrap_unionall(v); - if (jl_is_datatype(d) && d->name->wrapper == v && + if (jl_is_datatype(d) && jl_unwrap_unionall(d->name->wrapper) == (jl_value_t*)d && !module_in_worklist(d->name->module)) { write_uint8(s->s, 1); jl_serialize_value(s, d->name->module); diff --git a/test/precompile.jl b/test/precompile.jl index e9ccf795bde00..b275c6aa439e8 100644 --- a/test/precompile.jl +++ b/test/precompile.jl @@ -744,5 +744,27 @@ let end end +# issue #29936 +let + load_path = mktempdir() + load_cache_path = mktempdir() + try + write(joinpath(load_path, "Foo29936.jl"), + """ + module Foo29936 + const global m = Val{nothing}() + const global h = Val{:hey}() + wab = [("a", m), ("b", h),] + end + """) + pushfirst!(LOAD_PATH, load_path) + pushfirst!(DEPOT_PATH, load_cache_path) + @eval using Foo29936 + @test [("Plan", Foo29936.m), ("Plan", Foo29936.h),] isa Vector{Tuple{String,Val}} + finally + rm(load_path, recursive=true) + rm(load_cache_path, recursive=true) + end +end end # !withenv