Golang - fatal error: sync: RUnlock of unlocked RWMutex

I have a web application written in Golang. While running the application, during the very first request received, the application stops with this error:

1fatal error: sync: RUnlock of unlocked RWMutex

The full error is something like this:

 1fatal error: sync: RUnlock of unlocked RWMutex
 2
 3goroutine 10 [running]:
 4runtime.throw(0xb4aea5, 0x21)
 5/usr/local/go/src/runtime/panic.go:1112 +0x72 fp=0xc0003b0198 sp=0xc0003b0168 pc=0x439e72
 6sync.throw(0xb4aea5, 0x21)
 7/usr/local/go/src/runtime/panic.go:1098 +0x35 fp=0xc0003b01b8 sp=0xc0003b0198 pc=0x46c235
 8sync.(*RWMutex).rUnlockSlow(0xc0001c97a0, 0xffffffff)
 9/usr/local/go/src/sync/rwmutex.go:93 +0x3f fp=0xc0003b01e0 sp=0xc0003b01b8 pc=0x47c5bf
10sync.(*RWMutex).RUnlock(...)
11/usr/local/go/src/sync/rwmutex.go:83
12html/template.(*Template).wrapFuncs.func1(0xc000405470, 0x2, 0x2, 0x0, 0x0, 0x0)
13/usr/local/go/src/html/template/template.go:400 +0x1fb fp=0xc0003b0260 sp=0xc0003b01e0 pc=0x93b15b
14reflect.callReflect(0xc000288240, 0xc0003b03c8, 0xc0003b03b0)
15/usr/local/go/src/reflect/value.go:565 +0x32d fp=0xc0003b0398 sp=0xc0003b0260 pc=0x4a05ed
16reflect.makeFuncStub(0xa50080, 0xc000285a50, 0xc000285a40, 0x1, 0x1, 0x0, 0x0, 0x0, 0xc0003b0610, 0x49f727, ...)
17/usr/local/go/src/reflect/asm_amd64.s:22 +0x42 fp=0xc0003b03c8 sp=0xc0003b0398 pc=0x4aaba2
18runtime.call64(0xc000236e10, 0xc000288240, 0xc0002bf300, 0x2800000040)
19/usr/local/go/src/runtime/asm_amd64.s:548 +0x3e fp=0xc0003b0418 sp=0xc0003b03c8 pc=0x46f97e
20reflect.Value.call(0xa72320, 0xc000288240, 0x13, 0xb3215c, 0x4, 0xc000405440, 0x2, 0x2, 0xc0003b06b8, 0x1, ...)
21/usr/local/go/src/reflect/value.go:476 +0x8e7 fp=0xc0003b0620 sp=0xc0003b0418 pc=0x49f727
22reflect.Value.Call(0xa72320, 0xc000288240, 0x13, 0xc000405410, 0x2, 0x2, 0xfbebe0, 0x0, 0xc0003b0710)
23/usr/local/go/src/reflect/value.go:337 +0xb9 fp=0xc0003b06a0 sp=0xc0003b0620 pc=0x49ebf9
24text/template.safeCall(0xa72320, 0xc000288240, 0x13, 0xc000405410, 0x2, 0x2, 0x0, 0x0, 0x0, 0x0, ...)
25/usr/local/go/src/text/template/funcs.go:365 +0xbd fp=0xc0003b0720 sp=0xc0003b06a0 pc=0x7581dd
26text/template.(*state).evalCall(0xc0003b0fd8, 0xaa4160, 0xc000400000, 0x199, 0xa72320, 0xc000288240, 0x13, 0xc13158, 0xc000288c60, 0xc00028e17e, ...)
27/usr/local/go/src/text/template/exec.go:725 +0x689 fp=0xc0003b0850 sp=0xc0003b0720 pc=0x751909
28text/template.(*state).evalFunction(0xc0003b0fd8, 0xaa4160, 0xc000400000, 0x199, 0xc000288c90, 0xc13158, 0xc000288c60, 0xc000270a00, 0x3, 0x4, ...)
29/usr/local/go/src/text/template/exec.go:580 +0x172 fp=0xc0003b0938 sp=0xc0003b0850 pc=0x7502d2
30text/template.(*state).evalCommand(0xc0003b0fd8, 0xaa4160, 0xc000400000, 0x199, 0xc000288c60, 0xa7b8c0, 0xfece30, 0x99, 0xa75680, 0xc00035e810, ...)
31/usr/local/go/src/text/template/exec.go:467 +0x125 fp=0xc0003b0a08 sp=0xc0003b0938 pc=0x74e905
32text/template.(*state).evalPipeline(0xc0003b0fd8, 0xaa4160, 0xc000400000, 0x199, 0xc0001c9980, 0xa68bc0, 0xc000285a20, 0x94)
33/usr/local/go/src/text/template/exec.go:436 +0x125 fp=0xc0003b0af8 sp=0xc0003b0a08 pc=0x74e385
34text/template.(*state).walkIfOrWith(0xc0003b0fd8, 0xa, 0xaa4160, 0xc000400000, 0x199, 0xc0001c9980, 0xc000288cf0, 0x0)
35/usr/local/go/src/text/template/exec.go:285 +0xa9 fp=0xc0003b0ba8 sp=0xc0003b0af8 pc=0x74cf69
36text/template.(*state).walk(0xc0003b0fd8, 0xaa4160, 0xc000400000, 0x199, 0xc132c0, 0xc000270b00)
37/usr/local/go/src/text/template/exec.go:261 +0x285 fp=0xc0003b0c30 sp=0xc0003b0ba8 pc=0x74cbe5
38text/template.(*state).walk(0xc0003b0fd8, 0xaa4160, 0xc000400000, 0x199, 0xc13308, 0xc000288c00)
39/usr/local/go/src/text/template/exec.go:264 +0x13c fp=0xc0003b0cb8 sp=0xc0003b0c30 pc=0x74ca9c
40text/template.(*state).walkRange.func1(0xa4f4c0, 0xf6ae20, 0x82, 0xaa4160, 0xc000400000, 0x199)
41/usr/local/go/src/text/template/exec.go:351 +0x125 fp=0xc0003b0d08 sp=0xc0003b0cb8 pc=0x75d9c5
42text/template.(*state).walkRange(0xc0003b0fd8, 0xa75680, 0xc00035e810, 0x15, 0xc000270d00)
43/usr/local/go/src/text/template/exec.go:360 +0x2f8 fp=0xc0003b0e58 sp=0xc0003b0d08 pc=0x74d878
44text/template.(*state).walk(0xc0003b0fd8, 0xa75680, 0xc00035e810, 0x15, 0xc13428, 0xc000270d00)
45/usr/local/go/src/text/template/exec.go:267 +0x445 fp=0xc0003b0ee0 sp=0xc0003b0e58 pc=0x74cda5
46text/template.(*state).walk(0xc0003b0fd8, 0xa75680, 0xc00035e810, 0x15, 0xc13308, 0xc000288a80)

Probable reason

The reason might be, the application is compiled in one version of Linux but running in another version. At least in my case it happened. I just made sure both the linux versions are same, and the problem resolves itself.


comments powered by Disqus