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

panic: assertion failed [recovered] #59

Closed
l2dy opened this issue Sep 12, 2018 · 14 comments
Closed

panic: assertion failed [recovered] #59

l2dy opened this issue Sep 12, 2018 · 14 comments

Comments

@l2dy
Copy link

l2dy commented Sep 12, 2018

Describe the bug
revive panics.

To Reproduce
Steps to reproduce the behavior:

  1. I updated revive go get -u github.com/mgechev/revive
  2. I run it with the following flags & configuration file:
# flags

~/.gotools/bin/revive -config=$HOME/.revive.toml ./...
# config file
ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.8
errorCode = 0
warningCode = 0

[rule.blank-imports]
[rule.context-as-argument]
[rule.context-keys-type]
[rule.dot-imports]
[rule.error-return]
[rule.error-strings]
[rule.error-naming]
#[rule.exported]
[rule.if-return]
[rule.increment-decrement]
#[rule.var-naming]
[rule.var-declaration]
[rule.package-comments]
[rule.range]
#[rule.receiver-naming]
[rule.time-naming]
[rule.unexported-return]
[rule.indent-error-flow]
[rule.errorf]

Expected behavior
No panic.

Logs

[...]
vendor/github.com/apache/thrift/lib/go/thrift/server_socket.go:92:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
panic: assertion failed [recovered]
	panic: assertion failed

goroutine 1315 [running]:
go/types.(*Checker).handleBailout(0xc0005b6870, 0xc008cab800)
	/usr/local/go/src/go/types/check.go:236 +0x98
panic(0x12b3600, 0x1370730)
	/usr/local/go/src/runtime/panic.go:513 +0x1b9
go/types.assert(...)
	/usr/local/go/src/go/types/errors.go:18
go/types.(*Checker).recordTypeAndValue(0xc0005b6870, 0x0, 0x0, 0x3, 0x1374960, 0xc02fead160, 0x0, 0x0)
	/usr/local/go/src/go/types/check.go:281 +0x279
go/types.(*Checker).exprInternal(0xc0005b6870, 0xc02fed4e00, 0x13755a0, 0xc00a1ca800, 0x1374960, 0xc02fead160, 0x100b3c3)
	/usr/local/go/src/go/types/expr.go:1164 +0x17c4
go/types.(*Checker).rawExpr(0xc0005b6870, 0xc02fed4e00, 0x13755a0, 0xc00a1ca800, 0x1374960, 0xc02fead160, 0x100ba38)
	/usr/local/go/src/go/types/expr.go:969 +0x81
go/types.(*Checker).exprWithHint(0xc0005b6870, 0xc02fed4e00, 0x13755a0, 0xc00a1ca800, 0x1374960, 0xc02fead160)
	/usr/local/go/src/go/types/expr.go:1597 +0x73
go/types.(*Checker).indexedElts(0xc0005b6870, 0xc005257a00, 0x1c, 0x20, 0x1374960, 0xc02fead160, 0xffffffffffffffff, 0x1374960)
	/usr/local/go/src/go/types/expr.go:939 +0x1e2
go/types.(*Checker).exprInternal(0xc0005b6870, 0xc02fed4d00, 0x13755a0, 0xc00a1cb600, 0x0, 0x0, 0x101e728)
	/usr/local/go/src/go/types/expr.go:1158 +0x1759
go/types.(*Checker).rawExpr(0xc0005b6870, 0xc02fed4d00, 0x13755a0, 0xc00a1cb600, 0x0, 0x0, 0xc00028cd80)
	/usr/local/go/src/go/types/expr.go:969 +0x81
go/types.(*Checker).multiExpr(0xc0005b6870, 0xc02fed4d00, 0x13755a0, 0xc00a1cb600)
	/usr/local/go/src/go/types/expr.go:1575 +0x58
go/types.(*Checker).expr(0xc0005b6870, 0xc02fed4d00, 0x13755a0, 0xc00a1cb600)
	/usr/local/go/src/go/types/expr.go:1569 +0x49
go/types.(*Checker).varDecl(0xc0005b6870, 0xc011a03180, 0xc01ca5d008, 0x1, 0x1, 0x0, 0x0, 0x13755a0, 0xc00a1cb600)
	/usr/local/go/src/go/types/decl.go:425 +0x1b7
go/types.(*Checker).objDecl(0xc0005b6870, 0x1378080, 0xc011a03180, 0x0, 0xc008cab700, 0x0, 0x8)
	/usr/local/go/src/go/types/decl.go:244 +0x83c
go/types.(*Checker).packageObjects(0xc0005b6870)
	/usr/local/go/src/go/types/resolver.go:542 +0x26f
go/types.(*Checker).checkFiles(0xc0005b6870, 0xc00d253000, 0x1e, 0x20, 0x0, 0x0)
	/usr/local/go/src/go/types/check.go:250 +0xa5
go/types.(*Checker).Files(0xc0005b6870, 0xc00d253000, 0x1e, 0x20, 0xc00d0c47d0, 0xc00a68f030)
	/usr/local/go/src/go/types/check.go:241 +0x49
go/types.(*Config).Check(0xc00d0c68c0, 0xc010c98d17, 0x5, 0xc0021ccd40, 0xc00d253000, 0x1e, 0x20, 0xc00d0c4730, 0x101e728, 0xc0094dd940, ...)
	/usr/local/go/src/go/types/api.go:351 +0x11a
github.com/mgechev/revive/lint.(*Package).TypeCheck(0xc0021ccd80, 0xc0094dd940, 0xc011429880)
	/Users/sandbox/.gotools/src/github.com/mgechev/revive/lint/package.go:80 +0x351
github.com/mgechev/revive/rule.(*TimeNamingRule).Apply(0x15813c0, 0xc01240f740, 0x0, 0x0, 0x0, 0x1581568, 0x0, 0x0)
	/Users/sandbox/.gotools/src/github.com/mgechev/revive/rule/time-naming.go:25 +0xb6
github.com/mgechev/revive/lint.(*File).lint(0xc01240f740, 0xc00019e700, 0x10, 0x10, 0x0, 0x3fe999999999999a, 0xc0000146e0, 0x7, 0xc00000f710, 0x0, ...)
	/Users/sandbox/.gotools/src/github.com/mgechev/revive/lint/file.go:100 +0x36a
github.com/mgechev/revive/lint.(*Package).lint.func1(0xc00019e700, 0x10, 0x10, 0x0, 0x3fe999999999999a, 0xc0000146e0, 0x7, 0xc00000f710, 0x0, 0x0, ...)
	/Users/sandbox/.gotools/src/github.com/mgechev/revive/lint/package.go:157 +0x94
created by github.com/mgechev/revive/lint.(*Package).lint
	/Users/sandbox/.gotools/src/github.com/mgechev/revive/lint/package.go:156 +0x173

Desktop (please complete the following information):

  • OS: macOS 10.13
  • Go 1.11

Additional context
The repository tested is https://github.com/pingcap/tidb.

@mgechev
Copy link
Owner

mgechev commented Sep 12, 2018

I'll look at this over the weekend.

@mgechev
Copy link
Owner

mgechev commented Sep 15, 2018

@l2dy I cannot reproduce the issue using the same config, running the linter over thrift.

I'm using go version go1.11 darwin/amd64, macOS 10.31.6.

It'll be very useful if you can find which file causes the panic so I can take a further look.

@l2dy
Copy link
Author

l2dy commented Sep 16, 2018

running the linter over thrift

I'm testing https://github.com/pingcap/tidb, as noted at the end of the issue.

@mgechev
Copy link
Owner

mgechev commented Sep 16, 2018

Ups, missed that. Thanks!

@mgechev
Copy link
Owner

mgechev commented Sep 16, 2018

Still cannot reproduce the issue. Tried also to run dep ensure but still didn't hit the panic.

Would you also run golint ./... and golint ./types/field_type.go?

@l2dy
Copy link
Author

l2dy commented Sep 16, 2018

golint also crashes.

panic: assertion failed [recovered]
	panic: assertion failed

goroutine 1 [running]:
go/types.(*Checker).handleBailout(0xc000562000, 0xc000877628)
	/usr/local/go/src/go/types/check.go:236 +0x98
panic(0x1215c00, 0x12a6250)
	/usr/local/go/src/runtime/panic.go:513 +0x1b9
go/types.assert(...)
	/usr/local/go/src/go/types/errors.go:18
go/types.(*Checker).recordTypeAndValue(0xc000562000, 0x0, 0x0, 0x3, 0x12a9560, 0xc00055b840, 0x0, 0x0)
	/usr/local/go/src/go/types/check.go:281 +0x279
go/types.(*Checker).exprInternal(0xc000562000, 0xc000a6d940, 0x12a9fa0, 0xc0003f6f00, 0x12a9560, 0xc00055b840, 0x100b16f)
	/usr/local/go/src/go/types/expr.go:1164 +0x17c4
go/types.(*Checker).rawExpr(0xc000562000, 0xc000a6d940, 0x12a9fa0, 0xc0003f6f00, 0x12a9560, 0xc00055b840, 0x100b9f8)
	/usr/local/go/src/go/types/expr.go:969 +0x81
go/types.(*Checker).exprWithHint(0xc000562000, 0xc000a6d940, 0x12a9fa0, 0xc0003f6f00, 0x12a9560, 0xc00055b840)
	/usr/local/go/src/go/types/expr.go:1597 +0x73
go/types.(*Checker).indexedElts(0xc000562000, 0xc000369a00, 0x1c, 0x20, 0x12a9560, 0xc00055b840, 0xffffffffffffffff, 0x12a9560)
	/usr/local/go/src/go/types/expr.go:939 +0x1e2
go/types.(*Checker).exprInternal(0xc000562000, 0xc000a6d6c0, 0x12a9fa0, 0xc0003f7d00, 0x0, 0x0, 0x12a95a0)
	/usr/local/go/src/go/types/expr.go:1158 +0x1759
go/types.(*Checker).rawExpr(0xc000562000, 0xc000a6d6c0, 0x12a9fa0, 0xc0003f7d00, 0x0, 0x0, 0x0)
	/usr/local/go/src/go/types/expr.go:969 +0x81
go/types.(*Checker).multiExpr(0xc000562000, 0xc000a6d6c0, 0x12a9fa0, 0xc0003f7d00)
	/usr/local/go/src/go/types/expr.go:1575 +0x58
go/types.(*Checker).expr(0xc000562000, 0xc000a6d6c0, 0x12a9fa0, 0xc0003f7d00)
	/usr/local/go/src/go/types/expr.go:1569 +0x49
go/types.(*Checker).varDecl(0xc000562000, 0xc0012da9b0, 0xc000f2d4d8, 0x1, 0x1, 0x0, 0x0, 0x12a9fa0, 0xc0003f7d00)
	/usr/local/go/src/go/types/decl.go:425 +0x1b7
go/types.(*Checker).objDecl(0xc000562000, 0x12ac0c0, 0xc0012da9b0, 0x0, 0xc000877528, 0x0, 0x8)
	/usr/local/go/src/go/types/decl.go:244 +0x83c
go/types.(*Checker).packageObjects(0xc000562000)
	/usr/local/go/src/go/types/resolver.go:542 +0x26f
go/types.(*Checker).checkFiles(0xc000562000, 0xc0004b1400, 0x1e, 0x20, 0x0, 0x0)
	/usr/local/go/src/go/types/check.go:250 +0xa5
go/types.(*Checker).Files(0xc000562000, 0xc0004b1400, 0x1e, 0x20, 0xc000f12f50, 0xc0000894d0)
	/usr/local/go/src/go/types/check.go:241 +0x49
go/types.(*Config).Check(0xc00055e440, 0xc0007bf947, 0x5, 0xc000828240, 0xc0004b1400, 0x1e, 0x20, 0xc000f12eb0, 0x10d768e, 0x0, ...)
	/usr/local/go/src/go/types/api.go:351 +0x11a
golang.org/x/lint.(*pkg).typeCheck(0xc0002c6000, 0x38, 0x40)
	/Users/sandbox/.gotools/src/golang.org/x/lint/lint.go:283 +0x313
golang.org/x/lint.(*pkg).lint(0xc0002c6000, 0xc000341740, 0xc000229780, 0x18)
	/Users/sandbox/.gotools/src/golang.org/x/lint/lint.go:153 +0x40
golang.org/x/lint.(*Linter).LintFiles(0xc000a8da60, 0xc000a8dae8, 0xc000229820, 0x11, 0xc0002de220, 0x0, 0x0)
	/Users/sandbox/.gotools/src/golang.org/x/lint/lint.go:115 +0x634
main.lintFiles(0xc0005a6b40, 0x1e, 0x24)
	/Users/sandbox/.gotools/src/github.com/golang/lint/golint/golint.go:114 +0x1bd
main.lintImportedPackage(0xc00016d180, 0x0, 0x0)
	/Users/sandbox/.gotools/src/github.com/golang/lint/golint/golint.go:158 +0x30b
main.lintDir(0xc000264d19, 0x7)
	/Users/sandbox/.gotools/src/github.com/golang/lint/golint/golint.go:129 +0x60
main.main()
	/Users/sandbox/.gotools/src/github.com/golang/lint/golint/golint.go:75 +0x25d

@l2dy
Copy link
Author

l2dy commented Sep 16, 2018

Yes, ~/.gotools/bin/golint ./types/field_type.go crashes too.

@mgechev
Copy link
Owner

mgechev commented Sep 16, 2018

It's interesting that I was able to reproduce it once and since then everything passes successfully. I'll try again tomorrow.

@chavacava
Copy link
Collaborator

chavacava commented Sep 16, 2018

I can reproduce it systematically, using any typed rule.
For example, it fails with the following configuration

# config file
ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.8
errorCode = 0
warningCode = 0

[rule.context-keys-type]

@mgechev
Copy link
Owner

mgechev commented Sep 18, 2018

Would you have time to look at it? I still can't reproduce the problem.

@chavacava
Copy link
Collaborator

@mgechev, no problem. I will work on the problem from this Thursday.
It seems to be related to type checks.

@chavacava
Copy link
Collaborator

chavacava commented Sep 21, 2018

the problematic line is 484 in types/field_type.go, more precisely the declaration of fieldTypeMergeRules.

golint also fails on the same file.

I was unable to reproduce the bug in go 1.10

@chavacava
Copy link
Collaborator

chavacava commented Sep 21, 2018

We can add a recover to our function TypeCheck, the one that calls go's (buggy) check function.
I've made the modification and revive does not panic anymore.

chavacava added a commit to chavacava/revive that referenced this issue Sep 21, 2018
mgechev pushed a commit that referenced this issue Sep 21, 2018
@mgechev
Copy link
Owner

mgechev commented Sep 21, 2018

Closing the issue for now. Let's still keep an eye on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants