mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 13:03:39 +00:00
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:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user