天天看點

oftc注冊伺服器占用,golang伺服器程式運作過程中崩潰,報錯:fatal error: runtime: out of memory...

用golang編寫的遊戲伺服器程式,在接受來自用戶端的連結請求時有一定機率崩潰,崩潰時的列印如下:

fatal error: runtime: out of memory

runtime stack:

runtime.throw(0x81b890, 0x16)

/usr/local/go/src/runtime/panic.go:527 +0x90

runtime.sysMap(0xc8530d0000, 0x72730000, 0x9b8f00, 0x9d7b58)

/usr/local/go/src/runtime/mem_linux.go:203 +0x9b

runtime.mHeap_SysAlloc(0x9b8f00, 0x72730000, 0xc820000a80)

/usr/local/go/src/runtime/malloc.go:426 +0x160

runtime.mHeap_Grow(0x9b8f00, 0x39398, 0x0)

/usr/local/go/src/runtime/mheap.go:628 +0x63

runtime.mHeap_AllocSpanLocked(0x9b8f00, 0x39394, 0xc82009edc0)

/usr/local/go/src/runtime/mheap.go:532 +0x5f1

runtime.mHeap_Alloc_m(0x9b8f00, 0x39394, 0xffffff0100000000, 0xc820037ec8)

/usr/local/go/src/runtime/mheap.go:425 +0x1ac

runtime.mHeap_Alloc.func1()

/usr/local/go/src/runtime/mheap.go:484 +0x41

runtime.systemstack(0xc820037ee0)

/usr/local/go/src/runtime/asm_amd64.s:278 +0xab

runtime.mHeap_Alloc(0x9b8f00, 0x39394, 0x10100000000, 0xc82009e000)

/usr/local/go/src/runtime/mheap.go:485 +0x63

runtime.largeAlloc(0x72726f4c, 0xc800000001, 0x44fcc0)

/usr/local/go/src/runtime/malloc.go:748 +0xb3

runtime.mallocgc.func3()

/usr/local/go/src/runtime/malloc.go:637 +0x33

runtime.systemstack(0xc82001e000)

/usr/local/go/src/runtime/asm_amd64.s:262 +0x79

runtime.mstart()

/usr/local/go/src/runtime/proc1.go:668

goroutine 211 [running]:

runtime.systemstack_switch()

/usr/local/go/src/runtime/asm_amd64.s:216 fp=0xc820040890 sp=0xc820040888

runtime.mallocgc(0x72726f4c, 0x6ef040, 0x1, 0xc852bbe630)

/usr/local/go/src/runtime/malloc.go:638 +0x9c4 fp=0xc820040960 sp=0xc820040890

runtime.newarray(0x6ef040, 0x72726f4c, 0x40d5e6)

/usr/local/go/src/runtime/malloc.go:780 +0xc9 fp=0xc8200409a0 sp=0xc820040960

runtime.makeslice(0x6e1a80, 0x72726f4c, 0x72726f4c, 0x0, 0x0, 0x0)

/usr/local/go/src/runtime/slice.go:32 +0x165 fp=0xc8200409f0 sp=0xc8200409a0

github.com/chronicaww/gomsg.SingleRead(0xc84daaa798, 0x0, 0x0, 0x0, 0x0)

/Users/chronicaww/gopath/src/github.com/chronicaww/gomsg/msg.go:197 +0x69d fp=0xc820040cc0 sp=0xc8200409f0

_/Users/chronicaww/gitspace/moeMobileServer/player.readMsg(0xc84daaa798, 0xc850756cc0)

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:91 +0x189 fp=0xc820040db0 sp=0xc820040cc0

_/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).Start(0xc8200e0ea0, 0xc84daaa798, 0xc82001c1e0, 0xc82001c240, 0xc8200a4150, 0x10, 0x10, 0x4e2b, 0x0, 0x0, ...)

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:55 +0x371 fp=0xc820040f48 sp=0xc820040db0

main.acceptNewConn(0xc84daaa798)

/Users/chronicaww/gitspace/moeMobileServer/moeMobile.go:133 +0xab fp=0xc820040fa8 sp=0xc820040f48

runtime.goexit()

/usr/local/go/src/runtime/asm_amd64.s:1721 +0x1 fp=0xc820040fb0 sp=0xc820040fa8

created by main.main

/Users/chronicaww/gitspace/moeMobileServer/moeMobile.go:103 +0x6d5

goroutine 1 [IO wait]:

net.runtime_pollWait(0x7f31ebaae0d0, 0x72, 0xc8200101c0)

/usr/local/go/src/runtime/netpoll.go:157 +0x60

net.(*pollDesc).Wait(0xc820047a30, 0x72, 0x0, 0x0)

/usr/local/go/src/net/fd_poll_runtime.go:73 +0x3a

net.(*pollDesc).WaitRead(0xc820047a30, 0x0, 0x0)

/usr/local/go/src/net/fd_poll_runtime.go:78 +0x36

net.(*netFD).accept(0xc8200479d0, 0x0, 0x7f31ebaae5a0, 0xc852bb2400)

/usr/local/go/src/net/fd_unix.go:408 +0x27c

net.(*TCPListener).AcceptTCP(0xc82002a058, 0x873b08, 0x0, 0x0)

/usr/local/go/src/net/tcpsock_posix.go:254 +0x4d

main.main()

/Users/chronicaww/gitspace/moeMobileServer/moeMobile.go:102 +0x6b3

goroutine 17 [IO wait, 414 minutes]:

net.runtime_pollWait(0x7f31ebaae010, 0x72, 0xc8200101c0)

/usr/local/go/src/runtime/netpoll.go:157 +0x60

net.(*pollDesc).Wait(0xc8200a6300, 0x72, 0x0, 0x0)

/usr/local/go/src/net/fd_poll_runtime.go:73 +0x3a

net.(*pollDesc).WaitRead(0xc8200a6300, 0x0, 0x0)

/usr/local/go/src/net/fd_poll_runtime.go:78 +0x36

net.(*netFD).accept(0xc8200a62a0, 0x0, 0x7f31ebaae5a0, 0xc8200b01c0)

/usr/local/go/src/net/fd_unix.go:408 +0x27c

net.(*TCPListener).AcceptTCP(0xc8200b2010, 0xa, 0x0, 0x0)

/usr/local/go/src/net/tcpsock_posix.go:254 +0x4d

main.manage(0x7531)

/Users/chronicaww/gitspace/moeMobileServer/moeMobile.go:118 +0x159

created by main.main

/Users/chronicaww/gitspace/moeMobileServer/moeMobile.go:68 +0x1ec

goroutine 5 [select]:

_/Users/chronicaww/gitspace/moeMobileServer/glog.(*Log).processMsg(0xc8200ce000)

/Users/chronicaww/gitspace/moeMobileServer/glog/player.go:136 +0x310

created by _/Users/chronicaww/gitspace/moeMobileServer/glog.GetLogInstance

/Users/chronicaww/gitspace/moeMobileServer/glog/player.go:85 +0x428

goroutine 6 [select]:

_/Users/chronicaww/gitspace/moeMobileServer/playerlist.(*PlayerList).processMsg(0x9b11c0)

/Users/chronicaww/gitspace/moeMobileServer/playerlist/playerlist.go:48 +0x2c7

created by _/Users/chronicaww/gitspace/moeMobileServer/playerlist.(*PlayerList).Start

/Users/chronicaww/gitspace/moeMobileServer/playerlist/playerlist.go:33 +0x128

goroutine 201 [select]:

_/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).process(0xc8205b85b0)

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:112 +0x338

created by _/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).Start

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:52 +0x317

goroutine 200 [IO wait]:

net.runtime_pollWait(0x7f31ebaadb90, 0x72, 0xc8200101c0)

/usr/local/go/src/runtime/netpoll.go:157 +0x60

net.(*pollDesc).Wait(0xc84ddb7fe0, 0x72, 0x0, 0x0)

/usr/local/go/src/net/fd_poll_runtime.go:73 +0x3a

net.(*pollDesc).WaitRead(0xc84ddb7fe0, 0x0, 0x0)

/usr/local/go/src/net/fd_poll_runtime.go:78 +0x36

net.(*netFD).Read(0xc84ddb7f80, 0xc852bbe600, 0x8, 0x8, 0x0, 0x7f31ebaa8050, 0xc8200101c0)

/usr/local/go/src/net/fd_unix.go:232 +0x23a

net.(*conn).Read(0xc82002afb0, 0xc852bbe600, 0x8, 0x8, 0x8, 0x0, 0x0)

/usr/local/go/src/net/net.go:172 +0xe4

github.com/chronicaww/gomsg.SingleRead(0xc82002afb0, 0x0, 0x0, 0x0, 0x0)

/Users/chronicaww/gopath/src/github.com/chronicaww/gomsg/msg.go:168 +0x106

_/Users/chronicaww/gitspace/moeMobileServer/player.readMsg(0xc82002afb0, 0xc8502b4ae0)

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:91 +0x189

_/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).Start(0xc8205b85b0, 0xc82002afb0, 0xc82001c1e0, 0xc82001c240, 0xc8200a4150, 0x10, 0x10, 0x4e2b, 0x0, 0x0, ...)

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:55 +0x371

main.acceptNewConn(0xc82002afb0)

/Users/chronicaww/gitspace/moeMobileServer/moeMobile.go:133 +0xab

created by main.main

/Users/chronicaww/gitspace/moeMobileServer/moeMobile.go:103 +0x6d5

goroutine 196 [IO wait, 3 minutes]:

net.runtime_pollWait(0x7f31ebaadf50, 0x72, 0xc8200101c0)

/usr/local/go/src/runtime/netpoll.go:157 +0x60

net.(*pollDesc).Wait(0xc82049b8e0, 0x72, 0x0, 0x0)

/usr/local/go/src/net/fd_poll_runtime.go:73 +0x3a

net.(*pollDesc).WaitRead(0xc82049b8e0, 0x0, 0x0)

/usr/local/go/src/net/fd_poll_runtime.go:78 +0x36

net.(*netFD).Read(0xc82049b880, 0xc820353dc0, 0x8, 0x8, 0x0, 0x7f31ebaa8050, 0xc8200101c0)

/usr/local/go/src/net/fd_unix.go:232 +0x23a

net.(*conn).Read(0xc82002a0a8, 0xc820353dc0, 0x8, 0x8, 0x8, 0x0, 0x0)

/usr/local/go/src/net/net.go:172 +0xe4

github.com/chronicaww/gomsg.SingleRead(0xc82002a0a8, 0x0, 0x0, 0x0, 0x0)

/Users/chronicaww/gopath/src/github.com/chronicaww/gomsg/msg.go:168 +0x106

_/Users/chronicaww/gitspace/moeMobileServer/player.readMsg(0xc82002a0a8, 0xc8203942a0)

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:91 +0x189

_/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).Start(0xc8200e0340, 0xc82002a0a8, 0xc82001c1e0, 0xc82001c240, 0xc8200a4150, 0x10, 0x10, 0x4e2b, 0x0, 0x0, ...)

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:55 +0x371

main.acceptNewConn(0xc82002a0a8)

/Users/chronicaww/gitspace/moeMobileServer/moeMobile.go:133 +0xab

created by main.main

/Users/chronicaww/gitspace/moeMobileServer/moeMobile.go:103 +0x6d5

goroutine 197 [select]:

_/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).process(0xc8200e0340)

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:112 +0x338

created by _/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).Start

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:52 +0x317

goroutine 198 [runnable]:

time.Sleep(0xc350)

/usr/local/go/src/runtime/time.go:59 +0xf9

github.com/chronicaww/gomsg.SingleRead(0xc82002af70, 0x0, 0x0, 0x0, 0x0)

/Users/chronicaww/gopath/src/github.com/chronicaww/gomsg/msg.go:177 +0xb9b

_/Users/chronicaww/gitspace/moeMobileServer/player.readMsg(0xc82002af70, 0xc84dd3df80)

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:91 +0x189

_/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).Start(0xc8200afee0, 0xc82002af70, 0xc82001c1e0, 0xc82001c240, 0xc8200a4150, 0x10, 0x10, 0x4e2b, 0x0, 0x0, ...)

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:55 +0x371

main.acceptNewConn(0xc82002af70)

/Users/chronicaww/gitspace/moeMobileServer/moeMobile.go:133 +0xab

created by main.main

/Users/chronicaww/gitspace/moeMobileServer/moeMobile.go:103 +0x6d5

goroutine 199 [select]:

_/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).process(0xc8200afee0)

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:112 +0x338

created by _/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).Start

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:52 +0x317

goroutine 209 [running]:

goroutine running on other thread; stack unavailable

created by main.main

/Users/chronicaww/gitspace/moeMobileServer/moeMobile.go:103 +0x6d5

goroutine 210 [select]:

_/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).process(0xc8200ae000)

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:112 +0x338

created by _/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).Start

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:52 +0x317

goroutine 212 [select]:

_/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).process(0xc8200e0ea0)

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:112 +0x338

created by _/Users/chronicaww/gitspace/moeMobileServer/player.(*Player).Start

/Users/chronicaww/gitspace/moeMobileServer/player/player.go:52 +0x317