From 852702c6658bad250785a84864fdeb6c329173d7 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 4 Apr 2016 08:31:04 +0800 Subject: [PATCH] #17 goroutine: bugfix --- exec.v2/goroutine.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exec.v2/goroutine.go b/exec.v2/goroutine.go index cd7d92dc6..6e6d25711 100644 --- a/exec.v2/goroutine.go +++ b/exec.v2/goroutine.go @@ -14,9 +14,9 @@ type iGo struct { func (p *iGo) Exec(stk *Stack, ctx *Context) { go func() { - fn := NewFunction(nil, p.start, p.end, nil, false) - fn.parent = ctx - fn.ExtCall(nil) + cloneCtx := *ctx // 每个goroutine需要自己的上下文,有自己的堆栈 + cloneCtx.Stack = NewStack() + cloneCtx.Code.Exec(p.start, p.end, cloneCtx.Stack, &cloneCtx) }() stk.Push(nil) }