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 error: index out of range [XXX] with length YYY #1019

Open
1 task done
gandarez opened this issue Oct 29, 2024 · 0 comments
Open
1 task done

runtime error: index out of range [XXX] with length YYY #1019

gandarez opened this issue Oct 29, 2024 · 0 comments
Labels

Comments

@gandarez
Copy link
Contributor

gandarez commented Oct 29, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

At wakatime-cli we heavily use Chroma to find file dependencies and guess their programming languages. We also support parsing C files and extract this kind of information. Here's the function we get panic and the stack trace:

goroutine 1 [running]:
runtime/debug.Stack()
/opt/hostedtoolcache/go/1.22.5/x64/src/runtime/debug/stack.go:24 +0x5e
github.com/wakatime/wakatime-cli/cmd.runCmd.func1()
/home/runner/work/wakatime-cli/wakatime-cli/cmd/run.go:297 +0x148
panic({0xafc7a0?, 0xc0a6722c48?})
/opt/hostedtoolcache/go/1.22.5/x64/src/runtime/panic.go:770 +0x132
github.com/dlclark/regexp2.(*runner).backtrack(0xc00000003b?)
/home/runner/go/pkg/mod/github.com/dlclark/[email protected]/runner.go:1032 +0x1d5
github.com/dlclark/regexp2.(*runner).execute(0xc0002169a0)
/home/runner/go/pkg/mod/github.com/dlclark/[email protected]/runner.go:903 +0x36f9
github.com/dlclark/regexp2.(*runner).scan(0xc0002169a0, {0xc03cebe000?, 0xc000259430?, 0x419f05?}, 0xa57820?, 0x0, 0x2?)
/home/runner/go/pkg/mod/github.com/dlclark/[email protected]/runner.go:143 +0x2c6
github.com/dlclark/regexp2.(*Regexp).run(0xc000279080, 0x0, 0xd2be762, {0xc03cebe000, 0x10bbeda3, 0x10bbf000})
/home/runner/go/pkg/mod/github.com/dlclark/[email protected]/runner.go:90 +0xf9
github.com/dlclark/regexp2.(*Regexp).FindRunesMatchStartingAt(...)
/home/runner/go/pkg/mod/github.com/dlclark/[email protected]/regexp.go:206
github.com/alecthomas/chroma/v2.matchRules({0xc03cebe000, 0x10bbeda3, 0x10bbf000}, 0xd2be762, {0xc00011e400, 0x20, 0x4707d2?})
/home/runner/go/pkg/mod/github.com/alecthomas/chroma/[email protected]/regexp.go:452 +0xbd
github.com/alecthomas/chroma/v2.(*LexerState).Iterator(0xc000000480)
/home/runner/go/pkg/mod/github.com/alecthomas/chroma/[email protected]/regexp.go:212 +0x225
github.com/alecthomas/chroma/v2.Iterator.Tokens(0xc00026c020)
/home/runner/go/pkg/mod/github.com/alecthomas/chroma/[email protected]/iterator.go:15 +0x46
github.com/wakatime/wakatime-cli/pkg/deps.(*ParserC).Parse(0xc0001407e0, {0x7ffd80171f88, 0x2d})
/home/runner/work/wakatime-cli/wakatime-cli/pkg/deps/c.go:67 +0x24e
github.com/wakatime/wakatime-cli/pkg/deps.Detect({0x7ffd80171f88, 0x2d}, 0x0?)
/home/runner/work/wakatime-cli/wakatime-cli/pkg/deps/deps.go:129 +0x3e8
github.com/wakatime/wakatime-cli/cmd/heartbeat.initHandleOptions.WithDetection.func8.1({0xc000495b80, 0x1, 0x1})
/home/runner/work/wakatime-cli/wakatime-cli/pkg/deps/deps.go:68 +0x2a5
github.com/wakatime/wakatime-cli/cmd/heartbeat.initHandleOptions.WithDetection.func7.1({0xc000495b80, 0x1, 0x1})
/home/runner/work/wakatime-cli/wakatime-cli/pkg/language/language.go:54 +0x36c
github.com/wakatime/wakatime-cli/cmd/heartbeat.initHandleOptions.WithDetection.func6.1({0xc000495b80, 0x1, 0x1})
/home/runner/work/wakatime-cli/wakatime-cli/pkg/filestats/filestats.go:73 +0x546
github.com/wakatime/wakatime-cli/cmd/heartbeat.initHandleOptions.WithReplacing.func5.1({0xc000495b80, 0x1, 0x1})
/home/runner/work/wakatime-cli/wakatime-cli/pkg/apikey/apikey.go:44 +0x1cb
github.com/wakatime/wakatime-cli/cmd/heartbeat.initHandleOptions.WithDetection.func4.1({0xc0004957c0, 0x1, 0x0?})
/home/runner/work/wakatime-cli/wakatime-cli/pkg/remote/remote.go:112 +0x93c
github.com/wakatime/wakatime-cli/cmd/heartbeat.initHandleOptions.WithFiltering.func3.1({0xc0004f3a40, 0x1, 0x4c5c9b?})
/home/runner/work/wakatime-cli/wakatime-cli/pkg/filter/filter.go:41 +0x2d0
github.com/wakatime/wakatime-cli/cmd/heartbeat.initHandleOptions.WithEntityModifier.func2.1({0xc0004f3a40, 0x1, 0x1})
/home/runner/work/wakatime-cli/wakatime-cli/pkg/heartbeat/entity_modify.go:28 +0x302
github.com/wakatime/wakatime-cli/cmd/heartbeat.initHandleOptions.WithFormatting.func1.1({0xc0004f3a40, 0x1, 0x1})
/home/runner/work/wakatime-cli/wakatime-cli/pkg/heartbeat/format.go:32 +0x28e
github.com/wakatime/wakatime-cli/cmd/heartbeat.SendHeartbeats.NewHandle.func4({0xc0004f3a40, 0x1, 0x1})
/home/runner/work/wakatime-cli/wakatime-cli/pkg/heartbeat/heartbeat.go:175 +0xc8
github.com/wakatime/wakatime-cli/cmd/heartbeat.SendHeartbeats(0xc0006828c0, {0xc000174bd0, 0x2f})
/home/runner/work/wakatime-cli/wakatime-cli/cmd/heartbeat/heartbeat.go:140 +0x850
github.com/wakatime/wakatime-cli/cmd/heartbeat.Run(0xc0006828c0)
/home/runner/work/wakatime-cli/wakatime-cli/cmd/heartbeat/heartbeat.go:39 +0xc5
github.com/wakatime/wakatime-cli/cmd.runCmd(0xc0006828c0, 0x0, 0x0, 0xd3d8f0)
/home/runner/work/wakatime-cli/wakatime-cli/cmd/run.go:315 +0x127
github.com/wakatime/wakatime-cli/cmd.RunCmdWithOfflineSync(0xc0006828c0, 0x0, 0x0, 0x0?)
/home/runner/work/wakatime-cli/wakatime-cli/cmd/run.go:272 +0x25
github.com/wakatime/wakatime-cli/cmd.RunE(0xc0000e4308, 0xc0006828c0)
/home/runner/work/wakatime-cli/wakatime-cli/cmd/run.go:135 +0x945
github.com/wakatime/wakatime-cli/cmd.NewRootCMD.func1(0xc00011f000?, {0xb35a60?, 0x4?, 0xb35a64?})
/home/runner/work/wakatime-cli/wakatime-cli/cmd/root.go:32 +0x17
github.com/spf13/cobra.(*Command).execute(0xc0000e4308, {0xc000034100, 0xe, 0xe})
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:940 +0x882
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000e4308)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:992
github.com/wakatime/wakatime-cli/cmd.Execute()
/home/runner/work/wakatime-cli/wakatime-cli/cmd/root.go:301 +0x18
main.main()
/home/runner/work/wakatime-cli/wakatime-cli/main.go:6 +0xf

The error is always index out of range but it changes the length according to the size of the file, I guess.

To Reproduce

I do not have access to the file's content to reproduce the error because they run in the user's machine and it's protected by privacy.

@gandarez gandarez added the bug label Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant