Commit 8de0bb77 authored by Ian Lance Taylor's avatar Ian Lance Taylor

runtime: clear preemptStop in dropm

Updates #10958
Updates #24543
Fixes #35294

Change-Id: I60f024d08451565df6d9751dab9832b50cbf637a
Reviewed-on: https://go-review.googlesource.com/c/go/+/204957
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
parent 971ec872
......@@ -813,3 +813,52 @@ func TestCachedInstall(t *testing.T) {
t.Errorf("p.h not installed in second run: %v", err)
}
}
// Issue 35294.
func TestManyCalls(t *testing.T) {
t.Parallel()
defer func() {
os.Remove("testp7" + exeSuffix)
os.Remove("libgo7.a")
os.Remove("libgo7.h")
}()
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo7.a", "./libgo7")
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
}
checkLineComments(t, "libgo7.h")
ccArgs := append(cc, "-o", "testp7"+exeSuffix, "main7.c", "libgo7.a")
if runtime.Compiler == "gccgo" {
ccArgs = append(ccArgs, "-lgo")
}
if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
}
argv := cmdToRun("./testp7")
cmd = exec.Command(argv[0], argv[1:]...)
var sb strings.Builder
cmd.Stdout = &sb
cmd.Stderr = &sb
if err := cmd.Start(); err != nil {
t.Fatal(err)
}
timer := time.AfterFunc(time.Minute,
func() {
t.Error("test program timed out")
cmd.Process.Kill()
},
)
defer timer.Stop()
if err := cmd.Wait(); err != nil {
t.Log(sb.String())
t.Error(err)
}
}
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "C"
var sink []byte
//export GoFunction7
func GoFunction7() {
sink = make([]byte, 4096)
}
func main() {
}
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test that lots of calls don't deadlock.
#include <stdio.h>
#include "libgo7.h"
int main() {
int i;
for (i = 0; i < 100000; i++) {
GoFunction7();
}
}
......@@ -1625,6 +1625,7 @@ func dropm() {
// Return mp.curg to dead state.
casgstatus(mp.curg, _Gsyscall, _Gdead)
mp.curg.preemptStop = false
atomic.Xadd(&sched.ngsys, +1)
// Block signals before unminit.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment