golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.87k stars 17.65k forks source link

proposal: cmd/go: go test: set `GODEBUG=tracebackancestors` by default #69192

Closed myaaaaaaaaa closed 2 months ago

myaaaaaaaaa commented 2 months ago

Proposal Details

By default, a panicking goroutine's stack trace ends at the go line:

1725135532

The GODEBUG=tracebackancestors environment variable addresses this. Presumably, it has some kind of runtime cost that prevents it from being set by default - hence, this proposal to have it apply only during testing.

Having this on by default would improve the debugging experience for all users who need to work with goroutines.

gabyhelp commented 2 months ago

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

seankhliao commented 2 months ago

making code behave differently in tests than in normal operation sounds like a source for confusion. Like many testing functionality like race detection and coverage, it should be opt in, like it is now with GODEBUG.

ianlancetaylor commented 2 months ago

This would almost certainly break existing users who parse stack traces.

The information would be sometimes useful and sometimes not. Many servers can have hundreds or thousands of goroutines that all started at the same place, such as the server's call to Accept. Dumping the stack trace of the Accept call hundreds of times, even if only in a test, serves nobody.

Since we already have a way to do this, I'm going to close this proposal. Sorry.