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

Fix build error (nil pointer dereference) #78

Closed
enobufs opened this issue Jul 15, 2019 · 0 comments · Fixed by #79
Closed

Fix build error (nil pointer dereference) #78

enobufs opened this issue Jul 15, 2019 · 0 comments · Fixed by #79

Comments

@enobufs
Copy link
Member

enobufs commented Jul 15, 2019

Your environment.

  • Version: v1.3.0
  • Browser: n/a

What did you do?

CI reported build error (log shown below)

What did you expect?

Build and tests to pass

What happened?

=== RUN   TestServer/simple
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x68771e]
goroutine 32 [running]:
time.(*Timer).Stop(...)
	/home/travis/.gimme/versions/go1.12.7.linux.amd64/src/time/sleep.go:74
github.com/pion/turn/internal/client.(*Transaction).StopRtxTimer(0xc0001dc070)
	/home/travis/gopath/src/github.com/pion/turn/internal/client/transaction.go:75 +0xbe
github.com/pion/turn.(*Client).handleSTUNMessage(0xc0001b0240, 0xc0001fc000, 0x28, 0xffff, 0x998060, 0xc00020e000, 0xc00020e000, 0x0)
	/home/travis/gopath/src/github.com/pion/turn/client.go:474 +0x99c
github.com/pion/turn.(*Client).HandleInbound(0xc0001b0240, 0xc0001fc000, 0x28, 0xffff, 0x998060, 0xc00020e000, 0xc00020e000, 0x0, 0x0)
	/home/travis/gopath/src/github.com/pion/turn/client.go:400 +0x63c
github.com/pion/turn.(*Client).Listen.func1(0xc0001b0240)
	/home/travis/gopath/src/github.com/pion/turn/client.go:173 +0x18d
created by github.com/pion/turn.(*Client).Listen
	/home/travis/gopath/src/github.com/pion/turn/client.go:164 +0x1e1
FAIL	github.com/pion/turn	1.390s

This never happens on my PC, but I found a typo in the code. The nil check was done against a wrong variable:

// StopRtxTimer stop the transaction timer
func (t *Transaction) StopRtxTimer() {
	t.mutex.Lock()
	defer t.mutex.Unlock()

	if t != nil { // <----------------- :(  this should be t.time
		t.timer.Stop()
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant