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

Update package name parsing to match Go 1.20+ behavior #707

Closed
wants to merge 2 commits into from

Conversation

GregBrimble
Copy link

Go 1.20+ changed the compiler-generated symbols to use a colon rather than a period after go and type as the reserved prefixes (golang/go@0f8dffd).

This PR inspects the current runtime version and opt-in to the relevant behavior when trying to split a qualified function at the package name.

Fixes #180


return major, minor, nil
}

// packageName returns the package part of the symbol name, or the empty string
// if there is none.
// It replicates https://golang.org/pkg/debug/gosym/#Sym.PackageName, avoiding a
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change brings this function in line with the pkg/debug/gosym package that this was imported from: https://cs.opensource.google/go/go/+/refs/tags/go1.21.0:src/debug/gosym/symtab.go;l=64

stacktrace.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

Patch coverage is 43.47% of modified lines.

Files Changed Coverage
stacktrace.go 43.47%

📢 Thoughts on this report? Let us know!.

Copy link
Contributor

@tonyo tonyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey,

Thanks for the fix!
The change looks reasonable and we'd like to move forward with it, but there are two things that we'd like to see updated:

  1. goMajorMinorVersion memoization.
  2. Could you add some tests for the change? This test can be extended to test this new logic.

// they do not belong to any package.
//
// See cmd/compile/internal/base/link.go:ReservedImports variable.
major, minor, err := goMajorMinorVersion()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goMajorMinorVersion should ideally be called once (and then memoized), and not called on every frame.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, i wonder if the complexity introduced by trying to memoize this (at least how things are currently written) is worth it at the moment?

Copy link
Contributor

@greywolve greywolve Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this does increase the overhead a fair but. Some quick benches seem to show this is around 1.6x slower.

7200 ns/op vs 4300 ns/op.

I agree then, memoizing this makes sense.

@greywolve
Copy link
Contributor

I'm going to pick this one up.

@GregBrimble
Copy link
Author

Moved to #730

@GregBrimble GregBrimble closed this Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stacktrace for functions from "go.*" will have incorrect package name
6 participants