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: delineate multiple panics by adding newlines between them #23097

Open
dotaheor opened this issue Dec 12, 2017 · 5 comments
Open

runtime: delineate multiple panics by adding newlines between them #23097

dotaheor opened this issue Dec 12, 2017 · 5 comments
Labels
help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dotaheor
Copy link

dotaheor commented Dec 12, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.9.2 linux/amd64

What did you do?

// a.go
package main

func main() {
	var s []int
	var is interface{} = s
	go func() {
		_ = s == nil
	}()
	go func() {
		_ = is == is
	}()
	
	var m map[string]bool = nil
	_ = m["Go"]
	_, _ = m["Go"]
	m, _ = is.(map[string]bool)
	m = is.(map[string]bool)
}

What did you expect to see?

$ go run a.go
panic: interface conversion: interface {} is []int, not map[string]bool

goroutine 1 [running]:
main.main()
	/tmp/a.go:17 +0x15a
panic: runtime error: comparing uncomparable type []int

goroutine 19 [running]:
main.main.func2(0x45b480, 0x4cc2c0)
	/tmp/a.go:10 +0x3a
created by main.main
	/tmp/a.go:9 +0xc9
exit status 2

What did you see instead?

$ go run a.go

panic: interface conversion: interface {} is []int, not map[string]bool
goroutine 1 [running]:
main.main()
	/tmp/a.go:17 +0x15a

panic: runtime error: comparing uncomparable type []int
goroutine 19 [running]:
main.main.func2(0x45b480, 0x4cc2c0)
	/tmp/a.go:10 +0x3a
created by main.main
	/tmp/a.go:9 +0xc9
exit status 2
@gopherbot gopherbot added this to the Proposal milestone Dec 12, 2017
@titanous
Copy link
Member

Can you describe in more detail what the differences are? Without running diff, it just looks like there's a newline in a different place.

@dotaheor
Copy link
Author

@titanous yes, the newline makes the messages get a better readability.

@odeke-em
Copy link
Member

Gotcha @dotaheor. So this looks to me like an improvement that can be implemented without having to be a proposal and I can work on this. @randall77 am I right to say that we can JustDoIt (randall ™)?

@odeke-em odeke-em changed the title proposal: cmd/compile: better format for multiple runtime panics cmd/compile: delineate multiple runtime panics with newlines between them Dec 16, 2017
@odeke-em odeke-em modified the milestones: Proposal, Go1.11 Dec 16, 2017
@odeke-em odeke-em removed the Proposal label Dec 16, 2017
@odeke-em odeke-em changed the title cmd/compile: delineate multiple runtime panics with newlines between them cmd/compile: delineate multiple runtime panics by adding newlines between them Dec 16, 2017
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 30, 2018
@ianlancetaylor ianlancetaylor changed the title cmd/compile: delineate multiple runtime panics by adding newlines between them runtime: delineate multiple panics by adding newlines between them Jun 30, 2018
@ianlancetaylor ianlancetaylor modified the milestones: Go1.11, Unplanned Jun 30, 2018
@dotaheor
Copy link
Author

dotaheor commented Feb 7, 2019

It looks this is caused by two panics are printed at the same time. Sometimes, their messages may intertwine.

@dotaheor
Copy link
Author

dotaheor commented Feb 7, 2019

Maybe add a print("\n") line before https://github.com/golang/go/blob/master/src/runtime/panic.go#L819 is acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants