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

Handle panic for goInfo in Windows #1137

Merged
merged 1 commit into from
Dec 5, 2024
Merged

Conversation

gandarez
Copy link
Member

@gandarez gandarez commented Dec 4, 2024

This PR handles panic for Windows when goInfo fails to get system information and replaces the current goInfo by custom version v0.1.0-wakatime.10. It also fix two minor things in root.go and fileexperts.go

panic source code.

godebug: Value of name not listed in godebugs.All: winsymlink

goroutine 1 [running]:
runtime/debug.Stack()
C:/hostedtoolcache/windows/go/1.23.3/x64/src/runtime/debug/stack.go:26 +0x5e
github.com/wakatime/wakatime-cli/cmd.runCmd.func1()
D:/a/wakatime-cli/wakatime-cli/cmd/run.go:317 +0x134
panic({0x94fa00?, 0xc000304a70?})
C:/hostedtoolcache/windows/go/1.23.3/x64/src/runtime/panic.go:785 +0x132
internal/godebug.(*Setting).Value.func1()
C:/hostedtoolcache/windows/go/1.23.3/x64/src/internal/godebug/godebug.go:161 +0xb9
sync.(*Once).doSlow(0xc0001f3110?, 0x4?)
C:/hostedtoolcache/windows/go/1.23.3/x64/src/sync/once.go:76 +0xb4
sync.(*Once).Do(...)
C:/hostedtoolcache/windows/go/1.23.3/x64/src/sync/once.go:67
internal/godebug.(*Setting).Value(0x11c3ee0)
C:/hostedtoolcache/windows/go/1.23.3/x64/src/internal/godebug/godebug.go:158 +0x45
os.(*fileStat).Mode(0xc0001f3110)
C:/hostedtoolcache/windows/go/1.23.3/x64/src/os/types_windows.go:167 +0x2b
os.(*fileStat).IsDir(0xc0004813e0?)
C:/hostedtoolcache/windows/go/1.23.3/x64/src/os/types.go:61 +0x13
os/exec.chkStat({0xc0004813e0?, 0xc0001a2fd8?})
C:/hostedtoolcache/windows/go/1.23.3/x64/src/os/exec/lp_windows.go:24 +0x26
os/exec.findExecutable({0xc0001a2fd8, 0x17}, {0xc000141b00, 0xb, 0x64?})
C:/hostedtoolcache/windows/go/1.23.3/x64/src/os/exec/lp_windows.go:50 +0xd4
os/exec.lookPath({0xa49f74, 0x3}, {0xc000141b00, 0xb, 0x10})
C:/hostedtoolcache/windows/go/1.23.3/x64/src/os/exec/lp_windows.go:175 +0x395
os/exec.LookPath({0xa49f74, 0x3})
C:/hostedtoolcache/windows/go/1.23.3/x64/src/os/exec/lp_windows.go:71 +0x35
os/exec.Command({0xa49f74, 0x3}, {0xc000012a80, 0x1, 0x10000000000?})
C:/hostedtoolcache/windows/go/1.23.3/x64/src/os/exec/exec.go:425 +0x2db
github.com/matishsiao/goInfo.GetInfo()
C:/Users/runneradmin/go/pkg/mod/github.com/matishsiao/[email protected]/goInfo_windows.go:13 +0x8f
github.com/wakatime/wakatime-cli/pkg/heartbeat.UserAgent({0xd1f820?, 0xc000449ef0?}, {0xc00011e0c0, 0x1d})
D:/a/wakatime-cli/wakatime-cli/pkg/heartbeat/heartbeat.go:185 +0x7a
github.com/wakatime/wakatime-cli/cmd/heartbeat.buildHeartbeats({_, _}, {{{0x0, 0x0, 0x0}, 0x0, 0x0, {0xc0001c7320, 0xa}, {0xc000110090, ...}, ...}, ...})
D:/a/wakatime-cli/wakatime-cli/cmd/heartbeat/heartbeat.go:238 +0x45
github.com/wakatime/wakatime-cli/cmd/heartbeat.SendHeartbeats({0xd1f820, 0xc000449ef0}, 0xc000106a80, {0xc00013b580, 0x30})
D:/a/wakatime-cli/wakatime-cli/cmd/heartbeat/heartbeat.go:99 +0x308
github.com/wakatime/wakatime-cli/cmd/heartbeat.Run({0xd1f820, 0xc000449ef0}, 0xc000106a80)
D:/a/wakatime-cli/wakatime-cli/cmd/heartbeat/heartbeat.go:42 +0xd2
github.com/wakatime/wakatime-cli/cmd.runCmd({0xd1f820, 0xc000449ef0}, 0xc000106a80, 0x0, 0x0, 0xc56458)
D:/a/wakatime-cli/wakatime-cli/cmd/run.go:335 +0x183
github.com/wakatime/wakatime-cli/cmd.RunCmdWithOfflineSync({0xd1f820, 0xc000449ef0}, 0xc000106a80, 0x0, 0x0, 0x0?)
D:/a/wakatime-cli/wakatime-cli/cmd/run.go:290 +0x2c
github.com/wakatime/wakatime-cli/cmd.RunE(0xc00009c308, 0xc000106a80)
D:/a/wakatime-cli/wakatime-cli/cmd/run.go:145 +0x89a
github.com/wakatime/wakatime-cli/cmd.NewRootCMD.func1(0xc000141500?, {0xa4a3c4?, 0x4?, 0xa4a3c8?})
D:/a/wakatime-cli/wakatime-cli/cmd/root.go:32 +0x17
github.com/spf13/cobra.(*Command).execute(0xc00009c308, {0xc000140010, 0xa, 0xf})
C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:985 +0xaaa
github.com/spf13/cobra.(*Command).ExecuteC(0xc00009c308)
C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
C:/Users/runneradmin/go/pkg/mod/github.com/spf13/[email protected]/command.go:1041
github.com/wakatime/wakatime-cli/cmd.Execute()
D:/a/wakatime-cli/wakatime-cli/cmd/root.go:301 +0x18
main.main()
D:/a/wakatime-cli/wakatime-cli/main.go:6 +0xf

@gandarez gandarez self-assigned this Dec 4, 2024
@gandarez gandarez force-pushed the bugfix/user-agent-panic branch 2 times, most recently from c860e81 to 335e694 Compare December 4, 2024 12:23
@gandarez gandarez enabled auto-merge December 4, 2024 12:24
@gandarez gandarez force-pushed the bugfix/user-agent-panic branch 2 times, most recently from f716330 to 335e694 Compare December 5, 2024 00:29
@gandarez gandarez force-pushed the bugfix/user-agent-panic branch from 335e694 to aa0e781 Compare December 5, 2024 00:42
@gandarez gandarez merged commit 2bf7e0f into develop Dec 5, 2024
11 checks passed
@gandarez gandarez deleted the bugfix/user-agent-panic branch December 5, 2024 00:46
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 47.82609% with 12 lines in your changes missing coverage. Please review.

Project coverage is 62.92%. Comparing base (7a7af6a) to head (aa0e781).
Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
pkg/heartbeat/heartbeat.go 50.00% 10 Missing and 1 partial ⚠️
pkg/api/fileexperts.go 0.00% 1 Missing ⚠️
@@             Coverage Diff             @@
##           develop    #1137      +/-   ##
===========================================
- Coverage    62.95%   62.92%   -0.04%     
===========================================
  Files          386      386              
  Lines        16897    16912      +15     
===========================================
+ Hits         10638    10642       +4     
- Misses        5684     5694      +10     
- Partials       575      576       +1     
Flag Coverage Δ
unittests 62.92% <47.82%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cmd/root.go 0.00% <ø> (ø)
pkg/api/fileexperts.go 76.56% <0.00%> (ø)
pkg/heartbeat/heartbeat.go 78.18% <50.00%> (-8.14%) ⬇️

@alanhamlett alanhamlett mentioned this pull request Dec 5, 2024
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