runtime (wasm): scan the system stack

This saves the system stack pointer into a global and uses it to scan.
It should fix some use-after-free issues?
This commit is contained in:
Nia Waldvogel
2025-12-05 17:19:25 -05:00
committed by Ron Evans
parent 39e0333663
commit ee0a10ec51
3 changed files with 25 additions and 11 deletions
+7
View File
@@ -108,6 +108,10 @@ func (*stackState) unwind()
func (t *Task) Resume() {
// The current task must be saved and restored because this can nest on WASM with JS.
prevTask := currentTask
if prevTask == nil {
// Save the system stack pointer.
saveStackPointer()
}
t.gcData.swap()
currentTask = t
if !t.state.launched {
@@ -123,6 +127,9 @@ func (t *Task) Resume() {
}
}
//go:linkname saveStackPointer runtime.saveStackPointer
func saveStackPointer()
//export tinygo_rewind
func (*state) rewind()