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

Fix panicking when getting timezone #1014

Merged
merged 1 commit into from
Jan 16, 2024
Merged

Conversation

gandarez
Copy link
Member

This PR address an issue that happens only on Windows machines where it panics trying to load advapi32.dll to load registry. It early recover from panic avoiding breaking the cli and logs it.

Failed to load advapi32.dll: The paging file is too small for this operation to complete.

goroutine 1 [running]:
runtime/debug.Stack()
 C:/hostedtoolcache/windows/go/1.21.5/x64/src/runtime/debug/stack.go:24 +0x5e
github.com/wakatime/wakatime-cli/cmd.runCmd.func1()
 D:/a/wakatime-cli/wakatime-cli/cmd/run.go:313 +0x13c
panic({0xaa7260?, 0xc0004af020?})
 C:/hostedtoolcache/windows/go/1.21.5/x64/src/runtime/panic.go:914 +0x21f
syscall.(*LazyProc).mustFind(...)
 C:/hostedtoolcache/windows/go/1.21.5/x64/src/syscall/dll_windows.go:269
syscall.(*LazyProc).Addr(...)
 C:/hostedtoolcache/windows/go/1.21.5/x64/src/syscall/dll_windows.go:276
syscall.RegOpenKeyEx(0xb7981d?, 0x34?, 0x0, 0x1, 0x4281b3?)
 C:/hostedtoolcache/windows/go/1.21.5/x64/src/syscall/zsyscall_windows.go:317 +0xb4
golang.org/x/sys/windows/registry.OpenKey(0x19d25ee0108?, {0xb7981d?, 0x1266200?}, 0x4ee700?)
 C:/Users/runneradmin/go/pkg/mod/golang.org/x/[email protected]/windows/registry/key.go:84 +0x66
github.com/gandarez/go-olson-timezone.Name()
 C:/Users/runneradmin/go/pkg/mod/github.com/gandarez/[email protected]/timezone_windows.go:25 +0x65
github.com/wakatime/wakatime-cli/cmd/api.newClient({{0x0, 0x0, 0x0}, 0x0, 0x0, {0xc0004fa750, 0xe}, {0xc00002e3f0, 0x29}, {0x0, ...}, ...}, ...)
 D:/a/wakatime-cli/wakatime-cli/cmd/api/api.go:38 +0x1f2
github.com/wakatime/wakatime-cli/cmd/api.NewClient({{0x0, 0x0, 0x0}, 0x0, 0x0, {0xc0004fa750, 0xe}, {0xc00002e3f0, 0x29}, {0x0, ...}, ...})
 D:/a/wakatime-cli/wakatime-cli/cmd/api/api.go:24 +0xe8
github.com/wakatime/wakatime-cli/cmd/today.Today(0xc0004aed20?)
 D:/a/wakatime-cli/wakatime-cli/cmd/today/today.go:48 +0x1d8
github.com/wakatime/wakatime-cli/cmd/today.Run(0xe14380?)
 D:/a/wakatime-cli/wakatime-cli/cmd/today/today.go:18 +0x1c
github.com/wakatime/wakatime-cli/cmd.runCmd(0xc000502380, 0x0, 0x0, 0xd37c28)
 D:/a/wakatime-cli/wakatime-cli/cmd/run.go:331 +0x124
github.com/wakatime/wakatime-cli/cmd.RunCmd(0xc0004ebda0?, 0xee?, 0x2e?, 0x0?, 0xd37be0)
 D:/a/wakatime-cli/wakatime-cli/cmd/run.go:270 +0x18
github.com/wakatime/wakatime-cli/cmd.Run(0x0?, 0x0?)
 D:/a/wakatime-cli/wakatime-cli/cmd/run.go:119 +0x5c5
github.com/wakatime/wakatime-cli/cmd.NewRootCMD.func1(0xc0000b2c00?, {0xb42231?, 0x4?, 0xb42235?})
 D:/a/wakatime-cli/wakatime-cli/cmd/root.go:29 +0x17
github.com/spf13/cobra.(*Command).execute(0xc000584000, {0xc000122010, 0x5, 0x7})
 C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:944 +0x863
github.com/spf13/cobra.(*Command).ExecuteC(0xc000584000)
 C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
 C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:992
github.com/wakatime/wakatime-cli/cmd.Execute()
 D:/a/wakatime-cli/wakatime-cli/cmd/root.go:271 +0x18
main.main()
 D:/a/wakatime-cli/wakatime-cli/main.go:6 +0xf

@gandarez gandarez requested a review from alanhamlett January 16, 2024 13:59
@gandarez gandarez self-assigned this Jan 16, 2024
@gandarez gandarez force-pushed the bugfix/timezone-panic branch from dba54f8 to 49c9803 Compare January 16, 2024 14:01
@alanhamlett alanhamlett force-pushed the bugfix/timezone-panic branch from 49c9803 to 5739712 Compare January 16, 2024 17:13
@alanhamlett alanhamlett enabled auto-merge January 16, 2024 17:13
@alanhamlett alanhamlett merged commit e9d6c55 into develop Jan 16, 2024
11 checks passed
@alanhamlett alanhamlett deleted the bugfix/timezone-panic branch January 16, 2024 17:17
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

Successfully merging this pull request may close these issues.

2 participants