Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RWMutex panic stack is confuse #35614

Petelin opened this issue Nov 15, 2019 · 1 comment


Copy link

@Petelin Petelin commented Nov 15, 2019

this problem not happen in go1.10, but happen on go1.12,1.13

package main

import (

type client struct {

func (c *client) do() {
	defer c.RWMutex.Unlock()

func (c *client) do2() {

func main() {
	var c *client
	// c.do2()

what i expected is do and do2 should have almost same panic stack.

but the RLock panic print is not say c.RWMutext is nil point but RLock function have problem.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x104f17c]

goroutine 1 [running]:
        /Users/xiaolin.zhang/Project/gogo/test_main.go:13 +0x2c
        /Users/xiaolin.zhang/Project/gogo/test_main.go:24 +0x2a

This comment has been minimized.

Copy link

@randall77 randall77 commented Nov 15, 2019

This looks like it is already fixed at tip.
Up to go1.13 it looks like the nil check in do is dropped because there is an unconditional load in the inlined body of RLock that does the nil check for us. But that gives an extra stack frame that doesn't really make sense.
At tip we no longer do that. I'm not sure what CL fixed this, maybe CL 200197?

@randall77 randall77 closed this Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.