Skip to content

Commit 42da765

Browse files
aykevldeadprogram
authored andcommitted
compiler: don't use types in the global context
This usually works by chance, but leads to crashes. So we should never ever do this. I'm pretty sure this is the crash behind this issue: #3894 It may also have caused this crash: #3874 I have a suspicion this is also behind the rather crash-prone CircleCI jobs, that we haven't been able to find the source of. But we'll find out soon enough once this fix is merged. To avoid hitting this issue again in the future, I've created a PR to remove these dangerous functions altogether from the go-llvm API: tinygo-org/go-llvm#54
1 parent 8698a7e commit 42da765

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

compiler/interface.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (c *compilerContext) getTypeCode(typ types.Type) llvm.Value {
147147
c.addError(token.NoPos, fmt.Sprintf("too many levels of pointers for typecode: %s", typstr))
148148
}
149149
return llvm.ConstGEP(c.ctx.Int8Type(), ptr, []llvm.Value{
150-
llvm.ConstInt(llvm.Int32Type(), 1, false),
150+
llvm.ConstInt(c.ctx.Int32Type(), 1, false),
151151
})
152152
}
153153
}
@@ -452,8 +452,8 @@ func (c *compilerContext) getTypeCode(typ types.Type) llvm.Value {
452452
offset = 1
453453
}
454454
return llvm.ConstGEP(global.GlobalValueType(), global, []llvm.Value{
455-
llvm.ConstInt(llvm.Int32Type(), 0, false),
456-
llvm.ConstInt(llvm.Int32Type(), offset, false),
455+
llvm.ConstInt(c.ctx.Int32Type(), 0, false),
456+
llvm.ConstInt(c.ctx.Int32Type(), offset, false),
457457
})
458458
}
459459

0 commit comments

Comments
 (0)