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

runtime: Stack() output cannot be deduplicated #29769

Closed
RJPercival opened this issue Jan 16, 2019 · 8 comments
Closed

runtime: Stack() output cannot be deduplicated #29769

RJPercival opened this issue Jan 16, 2019 · 8 comments
Labels
FrozenDueToAge Proposal WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@RJPercival
Copy link

runtime.Stack() outputs the ID of the goroutine and addresses of function arguments. All of these differ between runs of a program. It would be nice if it was possible to pass an option that caused it to omit these details from the stacktrace, so that stacktraces can be deduplicated between runs (e.g. for reporting purposes).

@ianlancetaylor
Copy link
Contributor

It seems to me that this can be done easily enough by post processing the runtime.Stack output, and doing that would be preferable to making the implementation more complicated. I don't see why this needs to be in the standard library.

@RJPercival
Copy link
Author

There's no guarantee in the documentation for runtime.Stack() that the format will remain stable, so post-processing it may be unreliable (in fact, the format has already changed at least once). The implementation wouldn't gain much complexity, since it appears to already have a flags parameter internally and this would just involve not outputting a couple of things.

@ianlancetaylor
Copy link
Contributor

Personally, I don't think it's worth the cost.

In any case we clearly cannot change runtime.Stack, as that would break the Go 1 compatibility guarantee (https://golang.org/doc/go1compat). Do you want to propose a new API, either in the runtime or the runtime/debug package? Then we can turn this into a proposal (see https://golang.org/s/proposal).

@RJPercival
Copy link
Author

RJPercival commented Jan 16, 2019

Indeed, it would have to be a new function. I think it'd have to be in the runtime package, since the Stack() function in runtime/debug just calls runtime.Stack(). Having looked more closely at runtime.Stack(), it appears to already have a couple of options:

  • all - a parameter that controls whether to output a stacktrace for every goroutine.
  • tracebackancestors - an option set via the GODEBUG environment variable.

It might be cleanest to have both of these, along with a new option to control inclusion of the goroutine header and function argument addresses, passed into this new function in either a StackOpts struct or a flags int parameter.

@ianlancetaylor
Copy link
Contributor

I would not be optimistic about approving a function that is complex enough to require a StackOpts struct. We're talking about an unusual use case that will benefit few people. The cost in additional complexity has to be very very low.

@mark-rushakoff
Copy link
Contributor

https://github.com/maruel/panicparse "deduplicates redundant goroutine stacks" among some other useful utilities -- its source might be a good starting point for a third-party utility for deduplicating stack traces from separate crashes.

@bcmills
Copy link
Contributor

bcmills commented Jan 29, 2019

I think this is waiting on a concrete proposal (per #29769 (comment))?

@bcmills bcmills added Proposal WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jan 29, 2019
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Feb 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Proposal WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants