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 on specific comment #20

Closed
korjavin opened this issue Jun 14, 2021 · 4 comments
Closed

Panic on specific comment #20

korjavin opened this issue Jun 14, 2021 · 4 comments

Comments

@korjavin
Copy link

This comment:

/*r = regexp.MustCompile(
   `^\s*(?:[\pL]{3}-[0-9]{2}|[0-9]{2}-[\pL]{3})-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}\s[\pL]{1,6}\s*$`,
)*/  

leads to

ERRO [runner] Panic: godot: package "parser" (isInitialPkg: true, needAnalyzeSource: true): runtime error: index out of range [4] with length 4: goroutine 15833 [running]:
runtime/debug.Stack(0x11f3471, 0x3c, 0xc0019df3c8)
	runtime/debug/stack.go:24 +0x9f
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1(0xc0066f1800)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:101 +0x1be
panic(0x10c0460, 0xc001286a50)
	runtime/panic.go:965 +0x1b9
github.com/tetafro/godot.checkCommentForPeriod(0xc0020d3100, 0x4, 0xe9, 0xc002eb6000, 0x158, 0xc0010a02a0, 0x70, 0x114, 0x11, 0x2, ...)
	github.com/tetafro/[email protected]/checks.go:77 +0x4a5
github.com/tetafro/godot.checkComments(0xc001642a00, 0xe, 0xe, 0x119741f, 0xc, 0x0, 0x0, 0x0, 0x1, 0x0, ...)
	github.com/tetafro/[email protected]/checks.go:37 +0x2da
github.com/tetafro/godot.Run(0xc00ab55880, 0xc001334b00, 0x119741f, 0xc, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, ...)
	github.com/tetafro/[email protected]/godot.go:63 +0x2b0
github.com/golangci/golangci-lint/pkg/golinters.NewGodot.func1.1(0xc00cf864e0, 0x4ce0a9d4, 0x1aad340, 0xc005711e20, 0x2)
	github.com/golangci/golangci-lint/pkg/golinters/godot.go:50 +0x1a9
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc0066f1800)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:187 +0x9f2
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:105 +0x2a
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc0015b26e0, 0x113b7ec, 0x5, 0xc0031d1f70)
	github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x4d
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc0066f1800)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:104 +0x91
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc00a07d970, 0xc0066f1800)
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x65
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
	github.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x316 
@tetafro
Copy link
Owner

tetafro commented Jun 19, 2021

Can you provide a minimal example? I can't reproduce it. This one seems to work fine:

package main

import "fmt"

/*r = regexp.MustCompile(
   `^\s*(?:[\pL]{3}-[0-9]{2}|[0-9]{2}-[\pL]{3})-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}\s[\pL]{1,6}\s*$`,
)*/

func main() {
	fmt.Println("hello, world")
}
golangci-lint run --disable-all --enable godot

@sbueringer
Copy link
Contributor

sbueringer commented Aug 10, 2021

@tetafro Not sure if it's the same issue, but I also got a panic at the exact same line in checks.go (roughly, I'm using the v1.4.8 release of godot). In my case it seems to be the following line:

				"└─Object/child2", // last objects gets └─

https://github.com/kubernetes-sigs/cluster-api/blob/7478817225e0a75acb6e14fc7b438231578073d2/cmd/clusterctl/cmd/describe_cluster_test.go#L174

~/Downloads/godot ./cmd/clusterctl/cmd/describe_cluster_test.go -c ./.godot.yaml
panic: runtime error: slice bounds out of range [:50] with capacity 48

goroutine 1 [running]:
github.com/tetafro/godot.checkCommentForPeriod(0xc000180ad0, 0x1, 0xa1, 0xc00001c760, 0x19, 0x7ffeefbff4e2, 0x2d, 0x13be, 0xae, 0x1c, ...)
        /home/runner/work/godot/godot/checks.go:81 +0x498
github.com/tetafro/godot.checkComments(0xc0001880b0, 0x2, 0x2, 0xc0000146b0, 0x3, 0xc0000102c0, 0x4, 0x4, 0x101, 0x124a9a0, ...)
        /home/runner/work/godot/godot/checks.go:40 +0x2da
github.com/tetafro/godot.Run(0xc000026780, 0xc000010300, 0xc0000146b0, 0x3, 0xc0000102c0, 0x4, 0x4, 0x101, 0x0, 0x0, ...)
        /home/runner/work/godot/godot/godot.go:63 +0x2f0
main.main()
        /home/runner/work/godot/godot/cmd/godot/main.go:104 +0xb85

.godot.yaml

scope: all
period: true
capital: true

@tetafro
Copy link
Owner

tetafro commented Sep 4, 2021

I think I fixed it. At least it works for cluster-api repo. There was a problem with non-ascii characters.
Thanks for your reports.

@sbueringer
Copy link
Contributor

Thx!

@tetafro tetafro closed this as completed Nov 9, 2021
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