Skip to content

Commit

Permalink
codegen: add missing initialization for PhiC nodes (#43029)
Browse files Browse the repository at this point in the history
Our Phi handling assumes that it can references undefined memory, and
get back legal results, but our PhiC nodes were not initialized, so the
Phi node might see uninitialized results, and then cause the GC to
crash. This was observed in PkgEval on the PoreMatMod.jl package to
occur in recent Julia versions and master.
  • Loading branch information
vtjnash authored Nov 12, 2021
1 parent b71330d commit ec3ec02
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6424,8 +6424,11 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
Type *vtype = julia_type_to_llvm(ctx, jt, &isboxed);
assert(!isboxed);
assert(!type_is_ghost(vtype) && "constants should already be handled");
// CreateAlloca is OK during prologue setup
Value *lv = ctx.builder.CreateAlloca(vtype, NULL, jl_symbol_name(s));
Value *lv = new AllocaInst(vtype, 0, jl_symbol_name(s), /*InsertBefore*/ctx.pgcstack);
if (CountTrackedPointers(vtype).count) {
StoreInst *SI = new StoreInst(Constant::getNullValue(vtype), lv, false, Align(sizeof(void*)));
SI->insertAfter(ctx.pgcstack);
}
varinfo.value = mark_julia_slot(lv, jt, NULL, tbaa_stack);
alloc_def_flag(ctx, varinfo);
if (ctx.debug_enabled && varinfo.dinfo) {
Expand Down

0 comments on commit ec3ec02

Please sign in to comment.