Skip to content

Commit e95c0f8

Browse files
KenoJeffBezanson
authored andcommitted
Fix crash in Dict test
Fix the instance of assuming DataType that caused the crash in array.c and audit other uses, inserting appropriate assertions.
1 parent b1ece45 commit e95c0f8

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/cgutils.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ static DIType julia_type_to_di(jl_value_t *jt, DIBuilder *dbuilder, bool isboxed
212212
return ct;
213213
}
214214
else {
215+
assert(jl_is_datatype(jt));
215216
jdt->ditype = dbuilder->createTypedef(jl_pvalue_dillvmt,
216217
jl_symbol_name(jdt->name->name), NULL, 0, NULL);
217218
return (llvm::DIType*)jdt->ditype;

src/codegen.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -2750,6 +2750,7 @@ static bool emit_builtin_call(jl_cgval_t *ret, jl_value_t *f, jl_value_t **args,
27502750
sz = emit_datatype_nfields(boxed(arg1, ctx));
27512751
}
27522752
else {
2753+
assert(jl_is_datatype(aty));
27532754
sz = ConstantInt::get(T_size, jl_datatype_nfields(aty));
27542755
}
27552756
*ret = mark_julia_type(sz, false, jl_long_type, ctx);
@@ -2832,6 +2833,7 @@ static bool emit_builtin_call(jl_cgval_t *ret, jl_value_t *f, jl_value_t **args,
28322833
JL_GC_POP();
28332834
return false;
28342835
}
2836+
assert(jl_is_datatype(stt));
28352837

28362838
ssize_t fieldidx = -1;
28372839
if (jl_is_quotenode(args[2]) && jl_is_symbol(jl_fieldref(args[2], 0))) {

src/jltypes.c

+12-7
Original file line numberDiff line numberDiff line change
@@ -882,13 +882,18 @@ static jl_value_t *inst_datatype(jl_datatype_t *dt, jl_svec_t *p, jl_value_t **i
882882
size_t i;
883883
for(i=0; i < ntp; i++) {
884884
jl_value_t *pi = iparams[i];
885-
if (!jl_is_leaf_type(pi) || ((jl_datatype_t*)pi)->abstract) {
886-
// normalize types equal to wrappers
887-
jl_value_t *tw = extract_wrapper(pi);
888-
if (tw && tw != pi && jl_types_equal(pi, tw)) {
889-
iparams[i] = tw;
890-
if (p) jl_gc_wb(p, tw);
891-
}
885+
if (pi == jl_bottom_type)
886+
continue;
887+
if (jl_is_leaf_type(pi)) {
888+
assert(jl_is_datatype(pi));
889+
if (!((jl_datatype_t*)pi)->abstract)
890+
continue;
891+
}
892+
// normalize types equal to wrappers
893+
jl_value_t *tw = extract_wrapper(pi);
894+
if (tw && tw != pi && jl_types_equal(pi, tw)) {
895+
iparams[i] = tw;
896+
if (p) jl_gc_wb(p, tw);
892897
}
893898
}
894899
jl_value_t *lkup = (jl_value_t*)lookup_type(tn, iparams, ntp);

0 commit comments

Comments
 (0)