struct context maybe cause memory leak? #46

Closed
opened 2018-07-11 03:18:47 +00:00 by lunny · 11 comments
Owner

Author: @u0x01

memory leak in this case:

   24.51MB  1.77% 20.68%   327.24MB 23.58%  net/http.readRequest
  258.23MB 18.61% 39.29%   283.23MB 20.41%  net/textproto.(*Reader).ReadMIMEHeader

leak

see more: https://github.com/gorilla/sessions
see more: https://pathbox.github.io/2017/05/27/find-the-reason-memory-leak/

Important Note: If you aren't using gorilla/mux, you need to wrap your handlers with 
context.ClearHandler or else you will leak memory! An easy way to do this is to wrap the top-level mux when calling http.ListenAndServe:

http.ListenAndServe(":8080", context.ClearHandler(http.DefaultServeMux))
The ClearHandler function is provided by the gorilla/context package.

More examples are available on the Gorilla website.
Author: @u0x01 memory leak in this case: 24.51MB 1.77% 20.68% 327.24MB 23.58% net/http.readRequest 258.23MB 18.61% 39.29% 283.23MB 20.41% net/textproto.(*Reader).ReadMIMEHeader ![leak](https://user-images.githubusercontent.com/9703404/42548853-d27e9c70-84fb-11e8-9cfa-90aa2177cdcd.png) see more: https://github.com/gorilla/sessions see more: https://pathbox.github.io/2017/05/27/find-the-reason-memory-leak/ Important Note: If you aren't using gorilla/mux, you need to wrap your handlers with context.ClearHandler or else you will leak memory! An easy way to do this is to wrap the top-level mux when calling http.ListenAndServe: http.ListenAndServe(":8080", context.ClearHandler(http.DefaultServeMux)) The ClearHandler function is provided by the gorilla/context package. More examples are available on the Gorilla website.
Author
Owner

Author: @lunny

Could you give more testing details?

Author: @lunny Could you give more testing details?

遇到类似的问题,http post上传大文件后,出现memory leak的问题;

遇到类似的问题,http post上传大文件后,出现memory leak的问题;
Author
Owner

Have you close the ctx.Body after used it?

Have you close the `ctx.Body` after used it?

@lunny 你指的是“defer ctx.Req().Body.Close()”吗?

@lunny 你指的是“defer ctx.Req().Body.Close()”吗?
Author
Owner

Yes

Yes

尝试过,不过现象依旧。

尝试过,不过现象依旧。
Author
Owner

I will take a look at this recently.

I will take a look at this recently.

Thanks a million!

Thanks a million!

using tango version v0.6.1

coredump:

fatal error: runtime: out of memory

runtime stack:
runtime.throw(0xa3b6ef, 0x16)
        /usr/local/go/src/runtime/panic.go:605 +0x95
runtime.sysMap(0xc4fac60000, 0x7aa60000, 0x0, 0xde4e18)
        /usr/local/go/src/runtime/mem_linux.go:216 +0x1d0
runtime.(*mheap).sysAlloc(0xdcbb20, 0x7aa60000, 0x1)
        /usr/local/go/src/runtime/malloc.go:470 +0xd7
runtime.(*mheap).grow(0xdcbb20, 0x3d52f, 0x0)
        /usr/local/go/src/runtime/mheap.go:887 +0x60
runtime.(*mheap).allocSpanLocked(0xdcbb20, 0x3d52f, 0xde4e28, 0xdc3e70)
        /usr/local/go/src/runtime/mheap.go:800 +0x334
runtime.(*mheap).alloc_m(0xdcbb20, 0x3d52f, 0xffffffffffff0101, 0x7f3e5b7fddf8)
        /usr/local/go/src/runtime/mheap.go:666 +0x118
runtime.(*mheap).alloc.func1()
        /usr/local/go/src/runtime/mheap.go:733 +0x4d
runtime.systemstack(0x7f3e5b7fde10)
        /usr/local/go/src/runtime/asm_amd64.s:360 +0xab
runtime.(*mheap).alloc(0xdcbb20, 0x3d52f, 0x101, 0x7f3e5b7fde98)
        /usr/local/go/src/runtime/mheap.go:732 +0xa1
runtime.largeAlloc(0x7aa5e000, 0x7f3e5b7f0100, 0x433916)
        /usr/local/go/src/runtime/malloc.go:827 +0x98
runtime.mallocgc.func1()
        /usr/local/go/src/runtime/malloc.go:722 +0x46
runtime.systemstack(0xc42001f300)
        /usr/local/go/src/runtime/asm_amd64.s:344 +0x79
runtime.mstart()
        /usr/local/go/src/runtime/proc.go:1135

goroutine 126 [running]:
runtime.systemstack_switch()
        /usr/local/go/src/runtime/asm_amd64.s:298 fp=0xc420048d80 sp=0xc420048d78 pc=0x456b20
runtime.mallocgc(0x7aa5e000, 0x0, 0xdc3c00, 0x7f3e629ed718)
        /usr/local/go/src/runtime/malloc.go:721 +0x7ae fp=0xc420048e28 sp=0xc420048d80 pc=0x41229e
runtime.rawruneslice(0x1ea9709e, 0x0, 0x0, 0x0)
        /usr/local/go/src/runtime/string.go:273 +0xc6 fp=0xc420048e70 sp=0xc420048e28 pc=0x4468d6
runtime.stringtoslicerune(0xc420048f88, 0xc4204a8000, 0x1fdfac1c, 0x1ffffe00, 0xc4204a8000, 0x1fdfac1c)
        /usr/local/go/src/runtime/string.go:171 +0x163 fp=0xc420048ec8 sp=0xc420048e70 pc=0x4462d3
github.com/tango-contrib/debug.Debug.func1(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/tango-contrib/debug/debug.go:79 +0xd8f fp=0xc420049228 sp=0xc420048ec8 pc=0x7380cf
github.com/lunny/tango.HandlerFunc.Handle(0xc4200cee80, 0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc420049240 sp=0xc420049228 pc=0x729450
github.com/lunny/tango.(*Context).invoke(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc420049260 sp=0xc420049240 pc=0x7157a0
github.com/lunny/tango.(*Context).Next(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc420049278 sp=0xc420049260 pc=0x715236
github.com/lunny/tango.Contexts.func1(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:404 +0x43 fp=0xc4200492b8 sp=0xc420049278 pc=0x72a4c3
github.com/lunny/tango.HandlerFunc.Handle(0xa53210, 0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc4200492d0 sp=0xc4200492b8 pc=0x729450
github.com/lunny/tango.(*Context).invoke(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc4200492f0 sp=0xc4200492d0 pc=0x7157a0
github.com/lunny/tango.(*Context).Next(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc420049308 sp=0xc4200492f0 pc=0x715236
github.com/lunny/tango.Param.func1(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/param.go:347 +0x47 fp=0xc420049358 sp=0xc420049308 pc=0x72b057
github.com/lunny/tango.HandlerFunc.Handle(0xa53230, 0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc420049370 sp=0xc420049358 pc=0x729450
github.com/lunny/tango.(*Context).invoke(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc420049390 sp=0xc420049370 pc=0x7157a0
github.com/lunny/tango.(*Context).Next(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc4200493a8 sp=0xc420049390 pc=0x715236
github.com/lunny/tango.Return.func1(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/return.go:69 +0x71 fp=0xc420049698 sp=0xc4200493a8 pc=0x72b791
github.com/lunny/tango.HandlerFunc.Handle(0xa53240, 0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc4200496b0 sp=0xc420049698 pc=0x729450
github.com/lunny/tango.(*Context).invoke(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc4200496d0 sp=0xc4200496b0 pc=0x7157a0
github.com/lunny/tango.(*Context).Next(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc4200496e8 sp=0xc4200496d0 pc=0x715236
github.com/lunny/tango.Static.func1(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/static.go:49 +0x7b fp=0xc420049990 sp=0xc4200496e8 pc=0x72d2bb
github.com/lunny/tango.HandlerFunc.Handle(0xc4200ce2c0, 0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc4200499a8 sp=0xc420049990 pc=0x729450
github.com/lunny/tango.(*Context).invoke(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc4200499c8 sp=0xc4200499a8 pc=0x7157a0
github.com/lunny/tango.(*Context).Next(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc4200499e0 sp=0xc4200499c8 pc=0x715236
github.com/lunny/tango.Compresses.func1(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/compress.go:78 +0xa1 fp=0xc420049a28 sp=0xc4200499e0 pc=0x72a371
github.com/lunny/tango.HandlerFunc.Handle(0xc420010b50, 0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc420049a40 sp=0xc420049a28 pc=0x729450
github.com/lunny/tango.(*Context).invoke(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc420049a60 sp=0xc420049a40 pc=0x7157a0
github.com/lunny/tango.(*Context).Next(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc420049a78 sp=0xc420049a60 pc=0x715236
github.com/lunny/tango.Recovery.func1(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/recovery.go:44 +0x59 fp=0xc420049aa8 sp=0xc420049a78 pc=0x72b6f9
github.com/lunny/tango.HandlerFunc.Handle(0xc4200144d0, 0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc420049ac0 sp=0xc420049aa8 pc=0x729450
github.com/lunny/tango.(*Context).invoke(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc420049ae0 sp=0xc420049ac0 pc=0x7157a0
github.com/lunny/tango.(*Context).Next(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc420049af8 sp=0xc420049ae0 pc=0x715236
github.com/lunny/tango.Logging.func1(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/logger.go:59 +0x26a fp=0xc420049c08 sp=0xc420049af8 pc=0x72a94a
github.com/lunny/tango.HandlerFunc.Handle(0xa53220, 0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc420049c20 sp=0xc420049c08 pc=0x729450
github.com/lunny/tango.(*Context).invoke(0xc4201b6280)
        /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc420049c40 sp=0xc420049c20 pc=0x7157a0
github.com/lunny/tango.(*Tango).ServeHTTP(0xc42012a180, 0xd85bc0, 0xc420114700, 0xc4201be500)
        /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:185 +0x218 fp=0xc420049d18 sp=0xc420049c40 pc=0x7297c8
net/http.serverHandler.ServeHTTP(0xc420143c70, 0xd85bc0, 0xc420114700, 0xc4201be500)
        /usr/local/go/src/net/http/server.go:2619 +0xb4 fp=0xc420049d48 sp=0xc420049d18 pc=0x670884
net/http.(*conn).serve(0xc4201b65a0, 0xd86340, 0xc42013cd40)
        /usr/local/go/src/net/http/server.go:1801 +0x71d fp=0xc420049fc8 sp=0xc420049d48 pc=0x66cc0d
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc420049fd0 sp=0xc420049fc8 pc=0x459731
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2720 +0x288

goroutine 1 [IO wait]:
internal/poll.runtime_pollWait(0x7f3e62a30f70, 0x72, 0xffffffffffffffff)
        /usr/local/go/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc42012a718, 0x72, 0xc42004bb00, 0x0, 0x0)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:85 +0xae
internal/poll.(*pollDesc).waitRead(0xc42012a718, 0xffffffffffffff00, 0x0, 0x0)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Accept(0xc42012a700, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /usr/local/go/src/internal/poll/fd_unix.go:335 +0x1e2
net.(*netFD).accept(0xc42012a700, 0x412f59, 0xc42020c620, 0x981480)
        /usr/local/go/src/net/fd_unix.go:238 +0x42
net.(*TCPListener).accept(0xc42000f828, 0x981480, 0xc42004bcd0, 0x401a37)
        /usr/local/go/src/net/tcpsock_posix.go:136 +0x2e
net.(*TCPListener).AcceptTCP(0xc42000f828, 0xc42004bd18, 0xc42004bd20, 0xc42004bd10)
        /usr/local/go/src/net/tcpsock.go:234 +0x49
net/http.tcpKeepAliveListener.Accept(0xc42000f828, 0xa538b8, 0xc42020c5a0, 0xd86400, 0xc420144a50)
        /usr/local/go/src/net/http/server.go:3120 +0x2f
net/http.(*Server).Serve(0xc420143c70, 0xd85f40, 0xc42000f828, 0x0, 0x0)
        /usr/local/go/src/net/http/server.go:2695 +0x1b2
net/http.(*Server).ListenAndServe(0xc420143c70, 0xc420143c70, 0x0)
        /usr/local/go/src/net/http/server.go:2636 +0xa9
net/http.ListenAndServe(0xc42016ad20, 0xc, 0xd7fa00, 0xc42012a180, 0xc, 0xc420012fc0)
        /usr/local/go/src/net/http/server.go:2882 +0x7f
github.com/lunny/tango.(*Tango).Run(0xc42012a180, 0x0, 0x0, 0x0)
        /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:134 +0x157
main.main()
        /opt/TVCert/backend/src/waterdroplet/KeyService/main.go:46 +0x28a

goroutine 5 [sleep]:
time.Sleep(0x12a05f200)
        /usr/local/go/src/runtime/time.go:65 +0x130
waterdroplet/KeyService/user.checkTokenExpire()
        /opt/TVCert/backend/src/waterdroplet/KeyService/user/usermanager.go:62 +0x28d
created by waterdroplet/KeyService/user.init.0
        /opt/TVCert/backend/src/waterdroplet/KeyService/user/usermanager.go:35 +0x16c

goroutine 164 [IO wait]:
internal/poll.runtime_pollWait(0x7f3e62a30d30, 0x72, 0x0)
        /usr/local/go/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc4201b0718, 0x72, 0xffffffffffffff00, 0xd82600, 0xd7da70)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:85 +0xae
internal/poll.(*pollDesc).waitRead(0xc4201b0718, 0xc420426800, 0x1, 0x1)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc4201b0700, 0xc420426851, 0x1, 0x1, 0x0, 0x0, 0x0)
        /usr/local/go/src/internal/poll/fd_unix.go:126 +0x18a
net.(*netFD).Read(0xc4201b0700, 0xc420426851, 0x1, 0x1, 0x0, 0x0, 0x0)
        /usr/local/go/src/net/fd_unix.go:202 +0x52
net.(*conn).Read(0xc420234030, 0xc420426851, 0x1, 0x1, 0x0, 0x0, 0x0)
        /usr/local/go/src/net/net.go:176 +0x6d
net/http.(*connReader).backgroundRead(0xc420426840)
        /usr/local/go/src/net/http/server.go:660 +0x62
created by net/http.(*connReader).startBackgroundRead
        /usr/local/go/src/net/http/server.go:656 +0xd8
using tango version v0.6.1 coredump: ``` fatal error: runtime: out of memory runtime stack: runtime.throw(0xa3b6ef, 0x16) /usr/local/go/src/runtime/panic.go:605 +0x95 runtime.sysMap(0xc4fac60000, 0x7aa60000, 0x0, 0xde4e18) /usr/local/go/src/runtime/mem_linux.go:216 +0x1d0 runtime.(*mheap).sysAlloc(0xdcbb20, 0x7aa60000, 0x1) /usr/local/go/src/runtime/malloc.go:470 +0xd7 runtime.(*mheap).grow(0xdcbb20, 0x3d52f, 0x0) /usr/local/go/src/runtime/mheap.go:887 +0x60 runtime.(*mheap).allocSpanLocked(0xdcbb20, 0x3d52f, 0xde4e28, 0xdc3e70) /usr/local/go/src/runtime/mheap.go:800 +0x334 runtime.(*mheap).alloc_m(0xdcbb20, 0x3d52f, 0xffffffffffff0101, 0x7f3e5b7fddf8) /usr/local/go/src/runtime/mheap.go:666 +0x118 runtime.(*mheap).alloc.func1() /usr/local/go/src/runtime/mheap.go:733 +0x4d runtime.systemstack(0x7f3e5b7fde10) /usr/local/go/src/runtime/asm_amd64.s:360 +0xab runtime.(*mheap).alloc(0xdcbb20, 0x3d52f, 0x101, 0x7f3e5b7fde98) /usr/local/go/src/runtime/mheap.go:732 +0xa1 runtime.largeAlloc(0x7aa5e000, 0x7f3e5b7f0100, 0x433916) /usr/local/go/src/runtime/malloc.go:827 +0x98 runtime.mallocgc.func1() /usr/local/go/src/runtime/malloc.go:722 +0x46 runtime.systemstack(0xc42001f300) /usr/local/go/src/runtime/asm_amd64.s:344 +0x79 runtime.mstart() /usr/local/go/src/runtime/proc.go:1135 goroutine 126 [running]: runtime.systemstack_switch() /usr/local/go/src/runtime/asm_amd64.s:298 fp=0xc420048d80 sp=0xc420048d78 pc=0x456b20 runtime.mallocgc(0x7aa5e000, 0x0, 0xdc3c00, 0x7f3e629ed718) /usr/local/go/src/runtime/malloc.go:721 +0x7ae fp=0xc420048e28 sp=0xc420048d80 pc=0x41229e runtime.rawruneslice(0x1ea9709e, 0x0, 0x0, 0x0) /usr/local/go/src/runtime/string.go:273 +0xc6 fp=0xc420048e70 sp=0xc420048e28 pc=0x4468d6 runtime.stringtoslicerune(0xc420048f88, 0xc4204a8000, 0x1fdfac1c, 0x1ffffe00, 0xc4204a8000, 0x1fdfac1c) /usr/local/go/src/runtime/string.go:171 +0x163 fp=0xc420048ec8 sp=0xc420048e70 pc=0x4462d3 github.com/tango-contrib/debug.Debug.func1(0xc4201b6280) /opt/TVCert/backend/src/github.com/tango-contrib/debug/debug.go:79 +0xd8f fp=0xc420049228 sp=0xc420048ec8 pc=0x7380cf github.com/lunny/tango.HandlerFunc.Handle(0xc4200cee80, 0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc420049240 sp=0xc420049228 pc=0x729450 github.com/lunny/tango.(*Context).invoke(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc420049260 sp=0xc420049240 pc=0x7157a0 github.com/lunny/tango.(*Context).Next(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc420049278 sp=0xc420049260 pc=0x715236 github.com/lunny/tango.Contexts.func1(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:404 +0x43 fp=0xc4200492b8 sp=0xc420049278 pc=0x72a4c3 github.com/lunny/tango.HandlerFunc.Handle(0xa53210, 0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc4200492d0 sp=0xc4200492b8 pc=0x729450 github.com/lunny/tango.(*Context).invoke(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc4200492f0 sp=0xc4200492d0 pc=0x7157a0 github.com/lunny/tango.(*Context).Next(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc420049308 sp=0xc4200492f0 pc=0x715236 github.com/lunny/tango.Param.func1(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/param.go:347 +0x47 fp=0xc420049358 sp=0xc420049308 pc=0x72b057 github.com/lunny/tango.HandlerFunc.Handle(0xa53230, 0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc420049370 sp=0xc420049358 pc=0x729450 github.com/lunny/tango.(*Context).invoke(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc420049390 sp=0xc420049370 pc=0x7157a0 github.com/lunny/tango.(*Context).Next(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc4200493a8 sp=0xc420049390 pc=0x715236 github.com/lunny/tango.Return.func1(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/return.go:69 +0x71 fp=0xc420049698 sp=0xc4200493a8 pc=0x72b791 github.com/lunny/tango.HandlerFunc.Handle(0xa53240, 0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc4200496b0 sp=0xc420049698 pc=0x729450 github.com/lunny/tango.(*Context).invoke(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc4200496d0 sp=0xc4200496b0 pc=0x7157a0 github.com/lunny/tango.(*Context).Next(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc4200496e8 sp=0xc4200496d0 pc=0x715236 github.com/lunny/tango.Static.func1(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/static.go:49 +0x7b fp=0xc420049990 sp=0xc4200496e8 pc=0x72d2bb github.com/lunny/tango.HandlerFunc.Handle(0xc4200ce2c0, 0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc4200499a8 sp=0xc420049990 pc=0x729450 github.com/lunny/tango.(*Context).invoke(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc4200499c8 sp=0xc4200499a8 pc=0x7157a0 github.com/lunny/tango.(*Context).Next(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc4200499e0 sp=0xc4200499c8 pc=0x715236 github.com/lunny/tango.Compresses.func1(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/compress.go:78 +0xa1 fp=0xc420049a28 sp=0xc4200499e0 pc=0x72a371 github.com/lunny/tango.HandlerFunc.Handle(0xc420010b50, 0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc420049a40 sp=0xc420049a28 pc=0x729450 github.com/lunny/tango.(*Context).invoke(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc420049a60 sp=0xc420049a40 pc=0x7157a0 github.com/lunny/tango.(*Context).Next(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc420049a78 sp=0xc420049a60 pc=0x715236 github.com/lunny/tango.Recovery.func1(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/recovery.go:44 +0x59 fp=0xc420049aa8 sp=0xc420049a78 pc=0x72b6f9 github.com/lunny/tango.HandlerFunc.Handle(0xc4200144d0, 0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc420049ac0 sp=0xc420049aa8 pc=0x729450 github.com/lunny/tango.(*Context).invoke(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc420049ae0 sp=0xc420049ac0 pc=0x7157a0 github.com/lunny/tango.(*Context).Next(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:174 +0x36 fp=0xc420049af8 sp=0xc420049ae0 pc=0x715236 github.com/lunny/tango.Logging.func1(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/logger.go:59 +0x26a fp=0xc420049c08 sp=0xc420049af8 pc=0x72a94a github.com/lunny/tango.HandlerFunc.Handle(0xa53220, 0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:154 +0x30 fp=0xc420049c20 sp=0xc420049c08 pc=0x729450 github.com/lunny/tango.(*Context).invoke(0xc4201b6280) /opt/TVCert/backend/src/github.com/lunny/tango/context.go:222 +0x60 fp=0xc420049c40 sp=0xc420049c20 pc=0x7157a0 github.com/lunny/tango.(*Tango).ServeHTTP(0xc42012a180, 0xd85bc0, 0xc420114700, 0xc4201be500) /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:185 +0x218 fp=0xc420049d18 sp=0xc420049c40 pc=0x7297c8 net/http.serverHandler.ServeHTTP(0xc420143c70, 0xd85bc0, 0xc420114700, 0xc4201be500) /usr/local/go/src/net/http/server.go:2619 +0xb4 fp=0xc420049d48 sp=0xc420049d18 pc=0x670884 net/http.(*conn).serve(0xc4201b65a0, 0xd86340, 0xc42013cd40) /usr/local/go/src/net/http/server.go:1801 +0x71d fp=0xc420049fc8 sp=0xc420049d48 pc=0x66cc0d runtime.goexit() /usr/local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc420049fd0 sp=0xc420049fc8 pc=0x459731 created by net/http.(*Server).Serve /usr/local/go/src/net/http/server.go:2720 +0x288 goroutine 1 [IO wait]: internal/poll.runtime_pollWait(0x7f3e62a30f70, 0x72, 0xffffffffffffffff) /usr/local/go/src/runtime/netpoll.go:173 +0x57 internal/poll.(*pollDesc).wait(0xc42012a718, 0x72, 0xc42004bb00, 0x0, 0x0) /usr/local/go/src/internal/poll/fd_poll_runtime.go:85 +0xae internal/poll.(*pollDesc).waitRead(0xc42012a718, 0xffffffffffffff00, 0x0, 0x0) /usr/local/go/src/internal/poll/fd_poll_runtime.go:90 +0x3d internal/poll.(*FD).Accept(0xc42012a700, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0) /usr/local/go/src/internal/poll/fd_unix.go:335 +0x1e2 net.(*netFD).accept(0xc42012a700, 0x412f59, 0xc42020c620, 0x981480) /usr/local/go/src/net/fd_unix.go:238 +0x42 net.(*TCPListener).accept(0xc42000f828, 0x981480, 0xc42004bcd0, 0x401a37) /usr/local/go/src/net/tcpsock_posix.go:136 +0x2e net.(*TCPListener).AcceptTCP(0xc42000f828, 0xc42004bd18, 0xc42004bd20, 0xc42004bd10) /usr/local/go/src/net/tcpsock.go:234 +0x49 net/http.tcpKeepAliveListener.Accept(0xc42000f828, 0xa538b8, 0xc42020c5a0, 0xd86400, 0xc420144a50) /usr/local/go/src/net/http/server.go:3120 +0x2f net/http.(*Server).Serve(0xc420143c70, 0xd85f40, 0xc42000f828, 0x0, 0x0) /usr/local/go/src/net/http/server.go:2695 +0x1b2 net/http.(*Server).ListenAndServe(0xc420143c70, 0xc420143c70, 0x0) /usr/local/go/src/net/http/server.go:2636 +0xa9 net/http.ListenAndServe(0xc42016ad20, 0xc, 0xd7fa00, 0xc42012a180, 0xc, 0xc420012fc0) /usr/local/go/src/net/http/server.go:2882 +0x7f github.com/lunny/tango.(*Tango).Run(0xc42012a180, 0x0, 0x0, 0x0) /opt/TVCert/backend/src/github.com/lunny/tango/tan.go:134 +0x157 main.main() /opt/TVCert/backend/src/waterdroplet/KeyService/main.go:46 +0x28a goroutine 5 [sleep]: time.Sleep(0x12a05f200) /usr/local/go/src/runtime/time.go:65 +0x130 waterdroplet/KeyService/user.checkTokenExpire() /opt/TVCert/backend/src/waterdroplet/KeyService/user/usermanager.go:62 +0x28d created by waterdroplet/KeyService/user.init.0 /opt/TVCert/backend/src/waterdroplet/KeyService/user/usermanager.go:35 +0x16c goroutine 164 [IO wait]: internal/poll.runtime_pollWait(0x7f3e62a30d30, 0x72, 0x0) /usr/local/go/src/runtime/netpoll.go:173 +0x57 internal/poll.(*pollDesc).wait(0xc4201b0718, 0x72, 0xffffffffffffff00, 0xd82600, 0xd7da70) /usr/local/go/src/internal/poll/fd_poll_runtime.go:85 +0xae internal/poll.(*pollDesc).waitRead(0xc4201b0718, 0xc420426800, 0x1, 0x1) /usr/local/go/src/internal/poll/fd_poll_runtime.go:90 +0x3d internal/poll.(*FD).Read(0xc4201b0700, 0xc420426851, 0x1, 0x1, 0x0, 0x0, 0x0) /usr/local/go/src/internal/poll/fd_unix.go:126 +0x18a net.(*netFD).Read(0xc4201b0700, 0xc420426851, 0x1, 0x1, 0x0, 0x0, 0x0) /usr/local/go/src/net/fd_unix.go:202 +0x52 net.(*conn).Read(0xc420234030, 0xc420426851, 0x1, 0x1, 0x0, 0x0, 0x0) /usr/local/go/src/net/net.go:176 +0x6d net/http.(*connReader).backgroundRead(0xc420426840) /usr/local/go/src/net/http/server.go:660 +0x62 created by net/http.(*connReader).startBackgroundRead /usr/local/go/src/net/http/server.go:656 +0xd8 ```

since I delete t.Use(debug.Debug()), It seems to solved the problem.

since I delete t.Use(debug.Debug()), It seems to solved the problem.
Author
Owner

OK. This is affected by middleware debug.Debug which should not be enabled on production mode.

OK. This is affected by middleware `debug.Debug` which should not be enabled on production mode.
lunny closed this issue 2019-11-27 00:57:30 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lunny/tango#46
No description provided.