Skip to content

Commit 31d2cc3

Browse files
new
Change-Id: Ibfe3f33e832d84b1e02cba0e0eff379e8bc83c23
1 parent 849e8a2 commit 31d2cc3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/runtime/proc.go

+4
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ var initSigmask sigset
152152
func mainThreadDo(f func()) {
153153
gp := getg()
154154
if gp.m == &m0 {
155+
// lock os thread ensure that the main thread always
156+
// run only f during a call to f.
157+
lockOSThread()
158+
defer unlockOSThread()
155159
f()
156160
return
157161
}

0 commit comments

Comments
 (0)