mysteriumnetwork / go-openvpn

GNU Affero General Public License v3.0
119 stars 34 forks source link

Crash when switching the network #63

Closed 0x5e closed 2 years ago

0x5e commented 3 years ago

Step to reproduce:

  1. start the vpn
  2. switch the network from one wifi to another
  3. the program sometimes will crash.
libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: recursive_mutex lock failed: Invalid argument
SIGABRT: abort
PC=0x7fff20368462 m=7 sigcode=0

goroutine 0 [idle]:
runtime: unknown pc 0x7fff20368462
stack: frame={sp:0x2095977f8, fp:0x0} stack=[0x209518340,0x209597f40)
00000002095976f8:  0000000000000000  0000000000000000
0000000209597708:  0000000000000000  0000000000000000
0000000209597718:  0000000000000000  0000000000000000
0000000209597728:  0000000209597760  0000000000000000
0000000209597738:  0000000032aaaba2  0000000000000000
0000000209597748:  0000000000000000  0000000000000000
0000000209597758:  0000000209597890  0000000000000000
0000000209597768:  0000000032aaaba2  0000000000000000
0000000209597778:  0000000000000000  0000000000000000
0000000209597788:  0000000000000000  0000000000000000
0000000209597798:  0000000000000000  0000000000000000
00000002095977a8:  0000000000000003  0000000000000000
00000002095977b8:  0000000000000000  00007fff889cff80
00000002095977c8:  00007fff889f24e0  00007fff202a270c
00000002095977d8:  0000000000000000  0000000209597820
00000002095977e8:  00007fff202a5133  0000000000000000
00000002095977f8: <00007fff20396610  0000000000000003
0000000209597808:  00000002095979a0  0000000209597840
0000000209597818:  00007fff889f2ae0  0000000209597860
0000000209597828:  00007fff202e9720  8bc031d0d80a00cf
0000000209597838:  0000000209597960  00000002fffff9df
0000000209597848:  ffffffff00000008  0000000209597960
0000000209597858:  00007fff2035e2d4  0000000209597990
0000000209597868:  00007fff2035b418  0000003000000020
0000000209597878:  00000002095979a0  00000002095978b0
0000000209597888:  0000000061010001  0000003000000020
0000000209597898:  00000002095979a0  00000002095978b0
00000002095978a8:  000000c000364300  000000000478636e
00000002095978b8:  00007fff2035e35c  00000002095979a0
00000002095978c8:  000000002db05ef8  00007fff800aa238
00000002095978d8:  00000000044ca332  0000000000000000
00000002095978e8:  0000000004002dc0 <+0>  00000000044ca330
runtime: unknown pc 0x7fff20368462
stack: frame={sp:0x2095977f8, fp:0x0} stack=[0x209518340,0x209597f40)
00000002095976f8:  0000000000000000  0000000000000000
0000000209597708:  0000000000000000  0000000000000000
0000000209597718:  0000000000000000  0000000000000000
0000000209597728:  0000000209597760  0000000000000000
0000000209597738:  0000000032aaaba2  0000000000000000
0000000209597748:  0000000000000000  0000000000000000
0000000209597758:  0000000209597890  0000000000000000
0000000209597768:  0000000032aaaba2  0000000000000000
0000000209597778:  0000000000000000  0000000000000000
0000000209597788:  0000000000000000  0000000000000000
0000000209597798:  0000000000000000  0000000000000000
00000002095977a8:  0000000000000003  0000000000000000
00000002095977b8:  0000000000000000  00007fff889cff80
00000002095977c8:  00007fff889f24e0  00007fff202a270c
00000002095977d8:  0000000000000000  0000000209597820
00000002095977e8:  00007fff202a5133  0000000000000000
00000002095977f8: <00007fff20396610  0000000000000003
0000000209597808:  00000002095979a0  0000000209597840
0000000209597818:  00007fff889f2ae0  0000000209597860
0000000209597828:  00007fff202e9720  8bc031d0d80a00cf
0000000209597838:  0000000209597960  00000002fffff9df
0000000209597848:  ffffffff00000008  0000000209597960
0000000209597858:  00007fff2035e2d4  0000000209597990
0000000209597868:  00007fff2035b418  0000003000000020
0000000209597878:  00000002095979a0  00000002095978b0
0000000209597888:  0000000061010001  0000003000000020
0000000209597898:  00000002095979a0  00000002095978b0
00000002095978a8:  000000c000364300  000000000478636e
00000002095978b8:  00007fff2035e35c  00000002095979a0
00000002095978c8:  000000002db05ef8  00007fff800aa238
00000002095978d8:  00000000044ca332  0000000000000000
00000002095978e8:  0000000004002dc0 <+0>  00000000044ca330

goroutine 38 [syscall]:
runtime.cgocall(0x44cbbf0, 0xc00003ef88, 0xc00003ef00)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/runtime/cgocall.go:154 +0x5b fp=0xc00003ef58 sp=0xc00003ef20 pc=0x400649b
github.com/mysteriumnetwork/go-openvpn/openvpn3._Cfunc_stop_session(0x2db06a90)
    _cgo_gotypes.go:503 +0x3c fp=0xc00003ef88 sp=0xc00003ef58 pc=0x44b86bc
github.com/mysteriumnetwork/go-openvpn/openvpn3.(*Session).Start.func1.1.1(0x2db06a90)
    /Users/tuya/go/pkg/mod/github.com/a02683418/go-openvpn@v0.0.24-0.20210603063931-3a7015f88f7d/openvpn3/session.go:135 +0x4d fp=0xc00003efb8 sp=0xc00003ef88 pc=0x44ba3ed
github.com/mysteriumnetwork/go-openvpn/openvpn3.(*Session).Start.func1.1(0xc00007a5b0, 0x2db06a90)
    /Users/tuya/go/pkg/mod/github.com/a02683418/go-openvpn@v0.0.24-0.20210603063931-3a7015f88f7d/openvpn3/session.go:135 +0x45 fp=0xc00003efd0 sp=0xc00003efb8 pc=0x44ba445
runtime.goexit()
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/runtime/asm_amd64.s:1371 +0x1 fp=0xc00003efd8 sp=0xc00003efd0 pc=0x406ed21
created by github.com/mysteriumnetwork/go-openvpn/openvpn3.(*Session).Start.func1
    /Users/tuya/go/pkg/mod/github.com/a02683418/go-openvpn@v0.0.24-0.20210603063931-3a7015f88f7d/openvpn3/session.go:133 +0x485

goroutine 1 [IO wait]:
internal/poll.runtime_pollWait(0x6581e88, 0x72, 0x0)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/runtime/netpoll.go:222 +0x55
internal/poll.(*pollDesc).wait(0xc000078118, 0x72, 0x0, 0x0, 0x46e6bb7)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/internal/poll/fd_poll_runtime.go:87 +0x45
internal/poll.(*pollDesc).waitRead(...)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Accept(0xc000078100, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/internal/poll/fd_unix.go:401 +0x212
net.(*netFD).accept(0xc000078100, 0x1a54a204fe1e31a0, 0x262fe1e31a0, 0x100000001)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/net/fd_unix.go:172 +0x45
net.(*TCPListener).accept(0xc00000e198, 0x60bc674d, 0xc00021fcd0, 0x40c9bc6)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/net/tcpsock_posix.go:139 +0x32
net.(*TCPListener).Accept(0xc00000e198, 0xc00021fd20, 0x18, 0xc000000180, 0x42b0ffb)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/net/tcpsock.go:261 +0x65
net/http.(*Server).Serve(0xc0003bc0e0, 0x479b7f0, 0xc00000e198, 0x0, 0x0)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/net/http/server.go:2981 +0x285
net/http.(*Server).ListenAndServe(0xc0003bc0e0, 0xc0003bc0e0, 0xc00021fed0)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/net/http/server.go:2910 +0xba
net/http.ListenAndServe(...)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/net/http/server.go:3164
github.com/gin-gonic/gin.(*Engine).Run(0xc0003a4340, 0xc00021ff68, 0x1, 0x1, 0x0, 0x0)
    /Users/tuya/go/pkg/mod/github.com/gin-gonic/gin@v1.7.2/gin.go:336 +0x1ba
main.main()
    /Users/tuya/workspace/xiaozhi_desktop/xiaozhi_desktop/macos/xiaozhi-service/main.go:45 +0x34c

goroutine 40 [semacquire]:
sync.runtime_Semacquire(0xc00007a654)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/runtime/sema.go:56 +0x45
sync.(*WaitGroup).Wait(0xc00007a654)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/sync/waitgroup.go:130 +0x65
github.com/mysteriumnetwork/go-openvpn/openvpn3.(*Session).Start.func1.1(0xc00007a5b0, 0x2db05540)
    /Users/tuya/go/pkg/mod/github.com/a02683418/go-openvpn@v0.0.24-0.20210603063931-3a7015f88f7d/openvpn3/session.go:134 +0x33
created by github.com/mysteriumnetwork/go-openvpn/openvpn3.(*Session).Start.func1
    /Users/tuya/go/pkg/mod/github.com/a02683418/go-openvpn@v0.0.24-0.20210603063931-3a7015f88f7d/openvpn3/session.go:133 +0x485

goroutine 10 [syscall]:
github.com/mysteriumnetwork/go-openvpn/openvpn3._C2func_start_session(0x2db05540, 0x0, 0x0, 0x0)
    _cgo_gotypes.go:391 +0x50
github.com/mysteriumnetwork/go-openvpn/openvpn3.(*Session).Start.func1.3(0x2db05540, 0x470d368, 0xc00007a5b0, 0x2db05540)
    /Users/tuya/go/pkg/mod/github.com/a02683418/go-openvpn@v0.0.24-0.20210603063931-3a7015f88f7d/openvpn3/session.go:144 +0x4d
github.com/mysteriumnetwork/go-openvpn/openvpn3.(*Session).Start.func1(0xc00007a5b0)
    /Users/tuya/go/pkg/mod/github.com/a02683418/go-openvpn@v0.0.24-0.20210603063931-3a7015f88f7d/openvpn3/session.go:144 +0x4c8
created by github.com/mysteriumnetwork/go-openvpn/openvpn3.(*Session).Start
    /Users/tuya/go/pkg/mod/github.com/a02683418/go-openvpn@v0.0.24-0.20210603063931-3a7015f88f7d/openvpn3/session.go:107 +0x7d

goroutine 8 [IO wait]:
internal/poll.runtime_pollWait(0x6581cb8, 0x72, 0xffffffffffffffff)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/runtime/netpoll.go:222 +0x55
internal/poll.(*pollDesc).wait(0xc000078318, 0x72, 0x1000, 0x1000, 0xffffffffffffffff)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/internal/poll/fd_poll_runtime.go:87 +0x45
internal/poll.(*pollDesc).waitRead(...)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc000078300, 0xc00033f000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/internal/poll/fd_unix.go:166 +0x1d5
net.(*netFD).Read(0xc000078300, 0xc00033f000, 0x1000, 0x1000, 0x0, 0x6581cc0, 0x0)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/net/fd_posix.go:55 +0x4f
net.(*conn).Read(0xc000010090, 0xc00033f000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/net/net.go:183 +0x91
net/http.(*connReader).Read(0xc0003dd080, 0xc00033f000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/net/http/server.go:800 +0x1b9
bufio.(*Reader).fill(0xc000300240)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/bufio/bufio.go:101 +0x108
bufio.(*Reader).Peek(0xc000300240, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/bufio/bufio.go:139 +0x4f
net/http.(*conn).readRequest(0xc00038e780, 0x479cb98, 0xc0000283c0, 0x0, 0x0, 0x0)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/net/http/server.go:983 +0xec5
net/http.(*conn).serve(0xc00038e780, 0x479cc40, 0xc0000283c0)
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/net/http/server.go:1878 +0x705
created by net/http.(*Server).Serve
    /opt/homebrew/Cellar/go/1.16.4/libexec/src/net/http/server.go:3013 +0x39b

rax    0x0
rbx    0x209598000
rcx    0x209598000
rdx    0x0
rdi    0x3203
rsi    0x6
rbp    0x209597820
rsp    0x2095977f8
r8     0x2095976c0
r9     0x209597890
r10    0x209598000
r11    0xffffffffffffffff
r12    0x3203
r13    0x3000000008
r14    0x6
r15    0x16
rip    0x7fff20368462
rflags 0x246
cs     0x2b
fs     0x0
gs     0x0