[fatedier/frp]启动frpc时frps报错并停止运行

2024-06-27 985 views
6

报错信息如下

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x80df603]

goroutine 8 [running]:
frp/models/server.(*ProxyServer).Start(0x189254a0, 0x1898c060, 0x0, 0x0)
    /root/src/github.com/fatedier/frp/src/frp/models/server/server.go:103 +0x3d3
main.doLogin(0x1898c0f0, 0x1898c060, 0x1, 0x0, 0x0, 0x0)
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/control.go:231 +0x64b
main.controlWorker(0x1898c060)
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/control.go:71 +0x471
created by main.ProcessControlConn
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/control.go:38 +0x11b

goroutine 1 [chan receive]:
frp/utils/conn.(*Listener).Accept(0x1898a460, 0x84c695c, 0x0, 0x0)
    /root/src/github.com/fatedier/frp/src/frp/utils/conn/conn.go:75 +0x4a
main.ProcessControlConn(0x1898a460)
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/control.go:33 +0x2f
main.main()
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/main.go:162 +0x1217

goroutine 5 [IO wait]:
net.runtime_pollWait(0xb7618500, 0x72, 0x1897f180)
    /usr/lib/golang/src/runtime/netpoll.go:157 +0x55
net.(*pollDesc).Wait(0x18967438, 0x72, 0x0, 0x0)
    /usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x35
net.(*pollDesc).WaitRead(0x18967438, 0x0, 0x0)
    /usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x33
net.(*netFD).accept(0x18967400, 0x0, 0xb7618618, 0x1897f190)
    /usr/lib/golang/src/net/fd_unix.go:408 +0x20b
net.(*TCPListener).AcceptTCP(0x18827a70, 0x189674c0, 0x0, 0x0)
    /usr/lib/golang/src/net/tcpsock_posix.go:254 +0x47
frp/utils/conn.Listen.func1(0x18827a58)
    /root/src/github.com/fatedier/frp/src/frp/utils/conn/conn.go:53 +0x34
created by frp/utils/conn.Listen
    /root/src/github.com/fatedier/frp/src/frp/utils/conn/conn.go:68 +0x2b8

goroutine 6 [IO wait]:
net.runtime_pollWait(0xb7618488, 0x72, 0x1897f0c0)
    /usr/lib/golang/src/runtime/netpoll.go:157 +0x55
net.(*pollDesc).Wait(0x189675b8, 0x72, 0x0, 0x0)
    /usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x35
net.(*pollDesc).WaitRead(0x189675b8, 0x0, 0x0)
    /usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x33
net.(*netFD).accept(0x18967580, 0x0, 0xb7618618, 0x1897f0d0)
    /usr/lib/golang/src/net/fd_unix.go:408 +0x20b
net.(*TCPListener).AcceptTCP(0x18827ac8, 0x8093300, 0x0, 0x0)
    /usr/lib/golang/src/net/tcpsock_posix.go:254 +0x47
net/http.tcpKeepAliveListener.Accept(0x18827ac8, 0x0, 0x0, 0x0, 0x0)
    /usr/lib/golang/src/net/http/server.go:2135 +0x3d
net/http.(*Server).Serve(0x18967540, 0xb76185f8, 0x18827ac8, 0x0, 0x0)
    /usr/lib/golang/src/net/http/server.go:1887 +0x98
net/http.(*Server).ListenAndServe(0x18967540, 0x0, 0x0)
    /usr/lib/golang/src/net/http/server.go:1877 +0xe4
net/http.ListenAndServe(0x1897f060, 0xc, 0xb76185c0, 0x18900f50, 0x0, 0x0)
    /usr/lib/golang/src/net/http/server.go:1967 +0x7a
github.com/gin-gonic/gin.(*Engine).Run(0x18900f50, 0x18827a98, 0x1, 0x1, 0x0, 0x0)
    /root/src/github.com/fatedier/frp/Godeps/_workspace/src/github.com/gin-gonic/gin/gin.go:226 +0x15d
created by frp/models/server.RunDashboardServer
    /root/src/github.com/fatedier/frp/src/frp/models/server/dashboard.go:33 +0x28f

goroutine 7 [IO wait]:
net.runtime_pollWait(0xb7618410, 0x72, 0x1880e080)
    /usr/lib/golang/src/runtime/netpoll.go:157 +0x55
net.(*pollDesc).Wait(0x189676b8, 0x72, 0x0, 0x0)
    /usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x35
net.(*pollDesc).WaitRead(0x189676b8, 0x0, 0x0)
    /usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x33
net.(*netFD).Read(0x18967680, 0x1898e000, 0x1000, 0x1000, 0x0, 0xb7613030, 0x1880e080)
    /usr/lib/golang/src/net/fd_unix.go:232 +0x19a
net.(*conn).Read(0x18827ad0, 0x1898e000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/lib/golang/src/net/net.go:172 +0xb9
bufio.(*Reader).fill(0x1898c030)
    /usr/lib/golang/src/bufio/bufio.go:97 +0x172
bufio.(*Reader).ReadSlice(0x1898c030, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/lib/golang/src/bufio/bufio.go:328 +0x1b4
bufio.(*Reader).ReadBytes(0x1898c030, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/lib/golang/src/bufio/bufio.go:406 +0x8c
bufio.(*Reader).ReadString(0x1898c030, 0x18824f0a, 0x0, 0x0, 0x0, 0x0)
    /usr/lib/golang/src/bufio/bufio.go:446 +0x46
frp/utils/conn.(*Conn).ReadLine(0x1898c000, 0x0, 0x0, 0x0, 0x0)
    /root/src/github.com/fatedier/frp/src/frp/utils/conn/conn.go:132 +0x45
main.controlWorker(0x1898c000)
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/control.go:57 +0x75
created by main.ProcessControlConn
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/control.go:38 +0x11b
zonek@ubuntu-512mb-sfo1-01:~/bin/frp$ ls^C
zonek@ubuntu-512mb-sfo1-01:~/bin/frp$ sudo ./frps_linux_386 -c frps.ini 
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x80df603]

goroutine 7 [running]:
frp/models/server.(*ProxyServer).Start(0x189234a0, 0x18815fb0, 0x0, 0x0)
    /root/src/github.com/fatedier/frp/src/frp/models/server/server.go:103 +0x3d3
main.doLogin(0x1898c0c0, 0x18815fb0, 0x1, 0x0, 0x0, 0x0)
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/control.go:231 +0x64b
main.controlWorker(0x18815fb0)
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/control.go:71 +0x471
created by main.ProcessControlConn
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/control.go:38 +0x11b

goroutine 1 [chan receive]:
frp/utils/conn.(*Listener).Accept(0x1898a380, 0x84c695c, 0x0, 0x0)
    /root/src/github.com/fatedier/frp/src/frp/utils/conn/conn.go:75 +0x4a
main.ProcessControlConn(0x1898a380)
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/control.go:33 +0x2f
main.main()
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/main.go:162 +0x1217

goroutine 5 [IO wait]:
net.runtime_pollWait(0xb75ce508, 0x72, 0x1897f1b0)
    /usr/lib/golang/src/runtime/netpoll.go:157 +0x55
net.(*pollDesc).Wait(0x189673f8, 0x72, 0x0, 0x0)
    /usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x35
net.(*pollDesc).WaitRead(0x189673f8, 0x0, 0x0)
    /usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x33
net.(*netFD).accept(0x189673c0, 0x0, 0xb75ce620, 0x1897f1c0)
    /usr/lib/golang/src/net/fd_unix.go:408 +0x20b
net.(*TCPListener).AcceptTCP(0x18823a70, 0x18967480, 0x0, 0x0)
    /usr/lib/golang/src/net/tcpsock_posix.go:254 +0x47
frp/utils/conn.Listen.func1(0x18823a58)
    /root/src/github.com/fatedier/frp/src/frp/utils/conn/conn.go:53 +0x34
created by frp/utils/conn.Listen
    /root/src/github.com/fatedier/frp/src/frp/utils/conn/conn.go:68 +0x2b8

goroutine 6 [IO wait]:
net.runtime_pollWait(0xb75ce490, 0x72, 0x1897f0f0)
    /usr/lib/golang/src/runtime/netpoll.go:157 +0x55
net.(*pollDesc).Wait(0x18967578, 0x72, 0x0, 0x0)
    /usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x35
net.(*pollDesc).WaitRead(0x18967578, 0x0, 0x0)
    /usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x33
net.(*netFD).accept(0x18967540, 0x0, 0xb75ce620, 0x1897f100)
    /usr/lib/golang/src/net/fd_unix.go:408 +0x20b
net.(*TCPListener).AcceptTCP(0x18823ac8, 0x8093300, 0x0, 0x0)
    /usr/lib/golang/src/net/tcpsock_posix.go:254 +0x47
net/http.tcpKeepAliveListener.Accept(0x18823ac8, 0x0, 0x0, 0x0, 0x0)
    /usr/lib/golang/src/net/http/server.go:2135 +0x3d
net/http.(*Server).Serve(0x18967500, 0xb75ce600, 0x18823ac8, 0x0, 0x0)
    /usr/lib/golang/src/net/http/server.go:1887 +0x98
net/http.(*Server).ListenAndServe(0x18967500, 0x0, 0x0)
    /usr/lib/golang/src/net/http/server.go:1877 +0xe4
net/http.ListenAndServe(0x1897f090, 0xc, 0xb75ce5c8, 0x188fee70, 0x0, 0x0)
    /usr/lib/golang/src/net/http/server.go:1967 +0x7a
github.com/gin-gonic/gin.(*Engine).Run(0x188fee70, 0x18823a98, 0x1, 0x1, 0x0, 0x0)
    /root/src/github.com/fatedier/frp/Godeps/_workspace/src/github.com/gin-gonic/gin/gin.go:226 +0x15d
created by frp/models/server.RunDashboardServer
    /root/src/github.com/fatedier/frp/src/frp/models/server/dashboard.go:33 +0x28f

goroutine 8 [IO wait]:
net.runtime_pollWait(0xb75ce3a0, 0x72, 0x1880e0b0)
    /usr/lib/golang/src/runtime/netpoll.go:157 +0x55
net.(*pollDesc).Wait(0x18967738, 0x72, 0x0, 0x0)
    /usr/lib/golang/src/net/fd_poll_runtime.go:73 +0x35
net.(*pollDesc).WaitRead(0x18967738, 0x0, 0x0)
    /usr/lib/golang/src/net/fd_poll_runtime.go:78 +0x33
net.(*netFD).Read(0x18967700, 0x1898f000, 0x1000, 0x1000, 0x0, 0xb75c9030, 0x1880e0b0)
    /usr/lib/golang/src/net/fd_unix.go:232 +0x19a
net.(*conn).Read(0x18823ae0, 0x1898f000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/lib/golang/src/net/net.go:172 +0xb9
bufio.(*Reader).fill(0x1898c060)
    /usr/lib/golang/src/bufio/bufio.go:97 +0x172
bufio.(*Reader).ReadSlice(0x1898c060, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/lib/golang/src/bufio/bufio.go:328 +0x1b4
bufio.(*Reader).ReadBytes(0x1898c060, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/lib/golang/src/bufio/bufio.go:406 +0x8c
bufio.(*Reader).ReadString(0x1898c060, 0x1882170a, 0x0, 0x0, 0x0, 0x0)
    /usr/lib/golang/src/bufio/bufio.go:446 +0x46
frp/utils/conn.(*Conn).ReadLine(0x1898c030, 0x0, 0x0, 0x0, 0x0)
    /root/src/github.com/fatedier/frp/src/frp/utils/conn/conn.go:132 +0x45
main.controlWorker(0x1898c030)
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/control.go:57 +0x75
created by main.ProcessControlConn
    /root/src/github.com/fatedier/frp/src/frp/cmd/frps/control.go:38 +0x11b

回答

2

@daya-prac 是 v0.6.0 版本吗?配置文件的内容能不能贴一下。

2

@daya-prac 我好像定位到问题了,应该是你想用 http 服务转发,但是vhost_http_port 这个配置项没有填,所以默认没有启用,导致出错。vhost_http_port 是需要指定一个对外端口来接收所有的 http 的请求,例如 80 端口。

这是一个 bug,考虑改成如果 vhost_http_port 未指定,将会禁止 http 服务转发请求并提示错误信息,我会尽快修复,感谢反馈。