-
Notifications
You must be signed in to change notification settings - Fork 18.1k
cmd/internal/obj/x86, cmd/compile/internal/ssa: Possible lack of handling for panicIndex #31219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think panicSlice is in the same situation as panicIndex. |
Thanks. I will fix these. Both are optimizations that may not trigger because of the mismatch. |
Thank you for this report @nsajko! @randall77 thanks for taking this on! I've crafted for you a suggestion of a unit test that type stringerPlaceHolder string
func (sph stringerPlaceHolder) String() string {
return string(sph)
}
func TestNeedRaceCleanup_OpStaticCall(t *testing.T) {
mustTrigger := []string{
"runtime.racefuncenter", "runtime.racefuncexit",
"runtime.panicIndex", "runtime.panicSlice", "runtime.panicdivide",
"runtime.panicwrap", "runtime.panicshift",
}
t.Run("OpStaticCall", func(tt *testing.T) {
testNeedRaceCleanup(tt, OpStaticCall, mustTrigger, true)
})
t.Run("OpClosureCall", func(tt *testing.T) {
testNeedRaceCleanup(tt, OpClosureCall, mustTrigger, false)
})
t.Run("OpInterCall", func(tt *testing.T) {
testNeedRaceCleanup(tt, OpInterCall, mustTrigger, false)
})
}
func testNeedRaceCleanup(t *testing.T, op Op, names []string, want bool) {
for _, symName := range names {
v := &Value{
Block: &Block{
Func: &Func{
Config: &Config{Race: true},
Blocks: []*Block{
{
Values: []*Value{
{
Aux: stringerPlaceHolder(symName),
Op: op,
},
},
},
},
},
},
}
sym := stringerPlaceHolder("runtime.racefuncexit")
got := needRaceCleanup(sym, v)
if got != want {
t.Errorf("needRaceCleanup(%q)=%t want %t", symName, got, want)
}
}
} |
Change https://golang.org/cl/170639 mentions this issue: |
@odeke-em Thanks for the test, but I think I found a better way to test using our codegen framework. |
@randall77 cool, thanks for showing me that! I might be using the codegen framework in the near future and also writing such tests. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Not applicable, I think.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Notice that panicindex was renamed to panicIndex since the release. Then I found that references to the old panicindex still exist in the tip.
What did you expect to see?
I am guessing either panicIndex should be handled together with panicindex in the below files, or instead of panicindex. Sorry if this is not a bug, I am just guessing.
What did you see instead?
src/cmd/internal/obj/x86/obj6.go: case "runtime.panicindex", "runtime.panicslice", "runtime.panicdivide", "runtime.panicwrap", "runtime.panicshift":
src/cmd/compile/internal/ssa/rewrite.go: case "runtime.racefuncenter", "runtime.racefuncexit", "runtime.panicindex",
src/cmd/compile/internal/ssa/rewrite.go: "runtime.panicslice", "runtime.panicdivide", "runtime.panicwrap",
The text was updated successfully, but these errors were encountered: