mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-17 03:03:27 +00:00
compiler: track all pointers returned by runtime.alloc
In particular, track the pointers to the memory allocated for coroutine frames. Before this change, the following code would show memory corruption: https://github.com/johanbrandhorst/wasm-experiments/blob/master/canvas/main.go
This commit is contained in:
committed by
Ron Evans
parent
385d1d0a5d
commit
d49a363d0d
@@ -39,6 +39,9 @@ func (c *Compiler) emitPointerPack(values []llvm.Value) llvm.Value {
|
||||
// Packed data is bigger than a pointer, so allocate it on the heap.
|
||||
sizeValue := llvm.ConstInt(c.uintptrType, size, false)
|
||||
packedHeapAlloc = c.createRuntimeCall("alloc", []llvm.Value{sizeValue}, "")
|
||||
if c.needsStackObjects() {
|
||||
c.trackPointer(packedHeapAlloc)
|
||||
}
|
||||
packedAlloc = c.builder.CreateBitCast(packedHeapAlloc, llvm.PointerType(packedType, 0), "")
|
||||
}
|
||||
// Store all values in the alloca or heap pointer.
|
||||
|
||||
Reference in New Issue
Block a user