imgk / shadow

A rule-based transparent proxy for Windows, Linux, macOS
GNU General Public License v3.0
195 stars 43 forks source link

Golang runtime error with WinDivert on Windows #24

Open ghost opened 3 years ago

ghost commented 3 years ago

环境:

go version go1.16.2 windows/amd64
windows 10 64位

wintun好像没什么毛病,但是这个windivert 会崩溃

下面是输出日志:

PS D:\project\shadow> sudo .\shadow.exe -c .\v.json -v
shadow - a transparent proxy for Windows, Linux and macOS
shadow is running...
Infor: 2021/03/22 15:47:23 hijack 192.168.50.110:49306 <-UDP-> 192.168.50.1:53
Infor: 2021/03/22 15:47:23 hijack 192.168.50.110:61073 <-UDP-> 192.168.50.1:53
Infor: 2021/03/22 15:47:23 hijack 192.168.50.110:63128 <-UDP-> 192.168.50.1:53
Infor: 2021/03/22 15:47:23 queryd 192.168.50.110:49306 ask for vm.gtimg.cn.
Infor: 2021/03/22 15:47:23 queryd 192.168.50.110:61073 ask for btrace.video.qq.com.
Infor: 2021/03/22 15:47:23 queryd 192.168.50.110:63128 ask for v.qq.com.
runtime: setevent failed; errno=6
fatal error: runtime.semawakeup

runtime stack:
runtime.throw(0xb5b2ee, 0x12)
        runtime/panic.go:1117 +0x79
runtime.semawakeup.func1()
        runtime/os_windows.go:798 +0x85
runtime.semawakeup(0xc00005e400)
        runtime/os_windows.go:796 +0x51
runtime.notewakeup(0x105f9f8)
        runtime/lock_sema.go:161 +0x65
runtime.startTheWorldWithSema(0x388d01, 0x2083ffc6dcaa4)
        runtime/proc.go:1170 +0x1eb
runtime.gcMarkTermination.func3()
        runtime/mgc.go:1746 +0x2d
runtime.systemstack(0x0)
        runtime/asm_amd64.s:379 +0x6b
runtime.mstart()
        runtime/proc.go:1246

goroutine 86 [running]:
runtime.systemstack_switch()
        runtime/asm_amd64.s:339 fp=0xc0003e5d50 sp=0xc0003e5d48 pc=0x392680
runtime.gcMarkTermination(0x3ff178ed304294cd)
        runtime/mgc.go:1746 +0x40c fp=0xc0003e5f08 sp=0xc0003e5d50 pc=0x33e3ec
runtime.gcMarkDone()
        runtime/mgc.go:1623 +0x285 fp=0xc0003e5f60 sp=0xc0003e5f08 pc=0x33df25
runtime.gcBgMarkWorker()
        runtime/mgc.go:2045 +0x2e5 fp=0xc0003e5fe0 sp=0xc0003e5f60 pc=0x33f085
runtime.goexit()
        runtime/asm_amd64.s:1371 +0x1 fp=0xc0003e5fe8 sp=0xc0003e5fe0 pc=0x394521
created by runtime.gcBgMarkStartWorkers
        runtime/mgc.go:1835 +0x3e

goroutine 1 [chan receive]:
main.main()
        github.com/imgk/shadow/main.go:73 +0x4c8

goroutine 50 [select]:
github.com/imgk/shadow/pkg/divert.(*Device).loop(0xc000092040, 0x0, 0x0)
        github.com/imgk/shadow/pkg/divert/device.go:221 +0x1f1
created by github.com/imgk/shadow/pkg/divert.NewDevice
        github.com/imgk/shadow/pkg/divert/device.go:95 +0x97f

goroutine 52 [select]:
gvisor.dev/gvisor/pkg/sync.Gopark(...)
        gvisor.dev/gvisor@v0.0.0-20210312225833-f06f3af6e5eb/pkg/sync/runtime_unsafe.go:41
gvisor.dev/gvisor/pkg/sleep.(*Sleeper).nextWaker(0xc000080890, 0xc000067f01, 0x3a317b)
        gvisor.dev/gvisor@v0.0.0-20210312225833-f06f3af6e5eb/pkg/sleep/sleep_unsafe.go:181 +0x77
gvisor.dev/gvisor/pkg/sleep.(*Sleeper).Fetch(0xc000080890, 0xc000289501, 0x4, 0xb61199)
        gvisor.dev/gvisor@v0.0.0-20210312225833-f06f3af6e5eb/pkg/sleep/sleep_unsafe.go:228 +0x3f
gvisor.dev/gvisor/pkg/tcpip/transport/tcp.(*processor).start(0xc000080878, 0xc00039a10c)
        gvisor.dev/gvisor@v0.0.0-20210312225833-f06f3af6e5eb/pkg/tcpip/transport/tcp/dispatcher.go:96 +0x20a
created by gvisor.dev/gvisor/pkg/tcpip/transport/tcp.(*dispatcher).init
        gvisor.dev/gvisor@v0.0.0-20210312225833-f06f3af6e5eb/pkg/tcpip/transport/tcp/dispatcher.go:161 +0x170
imgk commented 3 years ago

Sometimes, it happens. However, I don't know how to solve this problem. I get nothing useful after googling this error code. According to the error information, this is related to Golang runtime.

ghost commented 3 years ago

Sometimes, it happens. However, I don't know how to solve this problem. I get nothing useful after googling this error code. According to the error information, this is related to Golang runtime.

这个报错有点奇怪,有时候频繁报错,有时候怎么都不报错,只能先这样,后面看看有没有办法处理