Revert "runtime/cgo: store M for C-created thread in pthread key"

This reverts CL 392854.

Reason for revert: caused #59294, which was derived from google
internal tests. The attempted fix of #59294 caused more breakage.

Change-Id: I5a061561ac2740856b7ecc09725ac28bd30f8bba
Reviewed-on: https://go-review.googlesource.com/c/go/+/481060
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Cherry Mui 2023-03-31 19:16:12 +00:00
parent 99276aeb5e
commit bfe3c678ab
37 changed files with 61 additions and 760 deletions

View file

@ -435,7 +435,7 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
c := &sigctxt{info, ctx}
gp := sigFetchG(c)
setg(gp)
if gp == nil || (gp.m != nil && gp.m.isExtraInC) {
if gp == nil {
if sig == _SIGPROF {
// Some platforms (Linux) have per-thread timers, which we use in
// combination with the process-wide timer. Avoid double-counting.
@ -458,18 +458,7 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
return
}
c.fixsigcode(sig)
// Set g to nil here and badsignal will use g0 by needm.
// TODO: reuse the current m here by using the gsignal and adjustSignalStack,
// since the current g maybe a normal goroutine and actually running on the signal stack,
// it may hit stack split that is not expected here.
if gp != nil {
setg(nil)
}
badsignal(uintptr(sig), c)
// Restore g
if gp != nil {
setg(gp)
}
return
}
@ -1136,9 +1125,8 @@ func sigfwdgo(sig uint32, info *siginfo, ctx unsafe.Pointer) bool {
// (1) we weren't in VDSO page,
// (2) we were in a goroutine (i.e., m.curg != nil), and
// (3) we weren't in CGO.
// (4) we weren't in dropped extra m.
gp := sigFetchG(c)
if gp != nil && gp.m != nil && gp.m.curg != nil && !gp.m.isExtraInC && !gp.m.incgo {
if gp != nil && gp.m != nil && gp.m.curg != nil && !gp.m.incgo {
return false
}