shayne / go-wsl2-host

Automatically update your Windows hosts file with the WSL2 VM IP address
1.65k stars 140 forks source link

Fails to start due to invalid memory address or nil pointer dereference #80

Open SliceCraft opened 1 year ago

SliceCraft commented 1 year ago

I've been using wsl2host for a few months now and it worked fine until I noticed it was acting weird today. Multiple times today I've had issues where a domain isn't pointing to an ip. While checking the event viewer I noticed a lot of errors. I assumed this might have to do with an update so I ran build.bat on the latest commit and used that executable to try again. Unfortunately without any luck. Below the output of 3 separate attempts at running wsl2host debug.

C:\Users\Slice\Documents\wsl2host>wsl2host.exe debug
wsl2host.info(1): starting wsl2host service
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0xfcccd7]

goroutine 1 [running]:
github.com/shayne/go-wsl2-host/cmd/wsl2host/pkg/service.updateHostIP({0x102fc68, 0xc000040640}, {0xc0001c0038, 0x1, 0xc00007bc58?})
        C:/Users/Slice/Documents/wsl2host/git/go-wsl2-host/cmd/wsl2host/pkg/service/service.go:109 +0x437
github.com/shayne/go-wsl2-host/cmd/wsl2host/pkg/service.Run({0x102fc68, 0xc000040640})
        C:/Users/Slice/Documents/wsl2host/git/go-wsl2-host/cmd/wsl2host/pkg/service/service.go:40 +0x76
github.com/shayne/go-wsl2-host/cmd/wsl2host/internal.(*windowserver).Execute(0xc0000521e0?, {0xc000040660, 0x1, 0x1}, 0xc000052120, 0x4?)
        C:/Users/Slice/Documents/wsl2host/git/go-wsl2-host/cmd/wsl2host/internal/service.go:34 +0x2f8
golang.org/x/sys/windows/svc/debug.Run({0xffb213, 0x8}, {0x102f628, 0x113e5b8})
        C:/Users/Slice/go/pkg/mod/golang.org/x/sys@v0.0.0-20190626221950-04f50cda93cb/windows/svc/debug/service.go:40 +0x144
github.com/shayne/go-wsl2-host/cmd/wsl2host/internal.RunService({0xffb213, 0x8}, 0x1)
        C:/Users/Slice/Documents/wsl2host/git/go-wsl2-host/cmd/wsl2host/internal/service.go:82 +0x210
main.main()
        C:/Users/Slice/Documents/wsl2host/git/go-wsl2-host/cmd/wsl2host/main.go:42 +0x14e

C:\Users\Slice\Documents\wsl2host>wsl2host.exe debug
wsl2host.info(1): starting wsl2host service
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
wsl2host.info(1): wsl2host-0
wsl2host.info(1): wsl2host service stopped

C:\Users\Slice\Documents\wsl2host>wsl2host.exe debug
wsl2host.info(1): starting wsl2host service
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
wsl2host.error(1): failed to get infos: failed to get IP for distro "Ubuntu": exit status 1
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0xfcccd7]

goroutine 1 [running]:
github.com/shayne/go-wsl2-host/cmd/wsl2host/pkg/service.updateHostIP({0x102fc68, 0xc000040640}, {0xc00000a070, 0x1, 0xffa39a?})
        C:/Users/Slice/Documents/wsl2host/git/go-wsl2-host/cmd/wsl2host/pkg/service/service.go:109 +0x437
github.com/shayne/go-wsl2-host/cmd/wsl2host/pkg/service.Run({0x102fc68, 0xc000040640})
        C:/Users/Slice/Documents/wsl2host/git/go-wsl2-host/cmd/wsl2host/pkg/service/service.go:40 +0x76
github.com/shayne/go-wsl2-host/cmd/wsl2host/internal.(*windowserver).Execute(0xc0000521e0?, {0xc000040660, 0x1, 0x1}, 0xc000052120, 0x4?)
        C:/Users/Slice/Documents/wsl2host/git/go-wsl2-host/cmd/wsl2host/internal/service.go:34 +0x2f8
golang.org/x/sys/windows/svc/debug.Run({0xffb213, 0x8}, {0x102f628, 0x113e5b8})
        C:/Users/Slice/go/pkg/mod/golang.org/x/sys@v0.0.0-20190626221950-04f50cda93cb/windows/svc/debug/service.go:40 +0x144
github.com/shayne/go-wsl2-host/cmd/wsl2host/internal.RunService({0xffb213, 0x8}, 0x1)
        C:/Users/Slice/Documents/wsl2host/git/go-wsl2-host/cmd/wsl2host/internal/service.go:82 +0x210
main.main()
        C:/Users/Slice/Documents/wsl2host/git/go-wsl2-host/cmd/wsl2host/main.go:42 +0x14e

C:\Users\Slice\Documents\wsl2host>