Skip to content
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

fix: go 1.21 adding goroutine ID to creator+location #685

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions gleak/goroutine/goroutine.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
// - "copystack"
// - "preempted"
// - ("???" ... something IS severely broken.)
//
// In case a goroutine is in waiting state, the State field instead starts with
// one of the following strings, never showing a lonely "waiting" string, but
// rather one of the reasons for waiting:
Expand Down Expand Up @@ -176,6 +177,9 @@ func findCreator(backtrace string) (creator, location string) {
}
location = strings.TrimSpace(details[1][:offsetpos])
creator = details[0]
if offsetpos := strings.LastIndex(creator, " in goroutine "); offsetpos >= 0 {
creator = creator[:offsetpos]
}
return
}

Expand Down
6 changes: 4 additions & 2 deletions gleak/ignoring_creator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ var _ = Describe("IgnoringCreator matcher", func() {
It("matches a creator function by full name", func() {
type T struct{}
pkg := reflect.TypeOf(T{}).PkgPath()
m := IgnoringCreator(pkg + ".creator")
ignore := pkg + ".creator"
m := IgnoringCreator(ignore)
g := creator()
Expect(m.Match(g)).To(BeTrue(), "creator %v", g.String())
Expect(m.Match(g)).To(BeTrue(), "creator: %v\ntried to ignore: %s",
g.String(), ignore)
Expect(m.Match(goroutine.Current())).To(BeFalse())
})

Expand Down