]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: call throw on systemstack in exitsyscall
authorAustin Clements <austin@google.com>
Wed, 22 Nov 2017 20:26:35 +0000 (15:26 -0500)
committerAustin Clements <austin@google.com>
Wed, 22 Nov 2017 21:44:35 +0000 (21:44 +0000)
If exitsyscall tries to grow the stack it will panic, but throw calls
print, which can grow the stack. Move the two bare throws in
exitsyscall to the system stack.

Updates #21431.

Change-Id: I5b29da5d34ade908af648a12075ed327a864476c
Reviewed-on: https://go-review.googlesource.com/79517
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/proc.go

index 0492a4139ddbad660fdb448d99c2c5daea7c4c1f..8cb6e57a9702d09138e21b04733d1c48bf76a309 100644 (file)
@@ -2939,7 +2939,9 @@ func exitsyscall(dummy int32) {
        oldp := _g_.m.p.ptr()
        if exitsyscallfast() {
                if _g_.m.mcache == nil {
-                       throw("lost mcache")
+                       systemstack(func() {
+                               throw("lost mcache")
+                       })
                }
                if trace.enabled {
                        if oldp != _g_.m.p.ptr() || _g_.m.syscalltick != _g_.m.p.ptr().syscalltick {
@@ -2986,7 +2988,9 @@ func exitsyscall(dummy int32) {
        mcall(exitsyscall0)
 
        if _g_.m.mcache == nil {
-               throw("lost mcache")
+               systemstack(func() {
+                       throw("lost mcache")
+               })
        }
 
        // Scheduler returned, so we're allowed to run now.