Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # 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 · 3 comments
Open
1 task done

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

gandarez opened this issue Oct 29, 2024 · 3 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/regexp2@v1.11.0/runner.go:1032 +0x1d5
github.com/dlclark/regexp2.(*runner).execute(0xc0002169a0)
/home/runner/go/pkg/mod/github.com/dlclark/regexp2@v1.11.0/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/regexp2@v1.11.0/runner.go:143 +0x2c6
github.com/dlclark/regexp2.(*Regexp).run(0xc000279080, 0x0, 0xd2be762, {0xc03cebe000, 0x10bbeda3, 0x10bbf000})
/home/runner/go/pkg/mod/github.com/dlclark/regexp2@v1.11.0/runner.go:90 +0xf9
github.com/dlclark/regexp2.(*Regexp).FindRunesMatchStartingAt(...)
/home/runner/go/pkg/mod/github.com/dlclark/regexp2@v1.11.0/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/v2@v2.14.0/regexp.go:452 +0xbd
github.com/alecthomas/chroma/v2.(*LexerState).Iterator(0xc000000480)
/home/runner/go/pkg/mod/github.com/alecthomas/chroma/v2@v2.14.0/regexp.go:212 +0x225
github.com/alecthomas/chroma/v2.Iterator.Tokens(0xc00026c020)
/home/runner/go/pkg/mod/github.com/alecthomas/chroma/v2@v2.14.0/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/cobra@v1.7.0/command.go:940 +0x882
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000e4308)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/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
@gandarez
Copy link
Contributor Author

gandarez commented Jan 5, 2025

nobody to help me? It's still happening in 2.14.0.

@alecthomas
Copy link
Owner

alecthomas commented Jan 5, 2025

Provide a way to reproduce it, or even better, send a PR.

@gandarez
Copy link
Contributor Author

gandarez commented Jan 9, 2025

@alecthomas this is a bug in the regexp2 library dlclark/regexp2#37

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

No branches or pull requests

2 participants