pion / stun

A Go implementation of STUN
https://pion.ly/
MIT License
625 stars 94 forks source link

atomic.LoadInt64 panics on ARM #16

Closed Moisesbr closed 5 years ago

Moisesbr commented 5 years ago

Running the gstreamer-receive example from (example-webrtc-applications), with TURN enable on ARMx32 plataform return panic error,

to enable Turn:

config := webrtc.Configuration{
    ICEServers: []webrtc.ICEServer{
      {
        URLs: []string{"turn:myserver.casainteligente.ind.br:3478"},
        Username: "myuser",
        Credential: "mypassword",
       },
    },
}

Panic Error:

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

goroutine 19 [running]:
runtime/internal/atomic.goLoad64(0x1485124, 0x6252625e, 0xbf35341d)
        /usr/local/go/src/runtime/internal/atomic/atomic_arm.go:127 +0x1c
github.com/pion/stun.(*Client).Start(0x1485110, 0x1490570, 0x147b6a0, 0x340fd8, 0x147df01)
        /root/go/src/github.com/pion/stun/client.go:607 +0x2e8
github.com/pion/stun.(*Client).Do(0x1485110, 0x1490570, 0x14825c0, 0x0, 0x0)
        /root/go/src/github.com/pion/stun/client.go:493 +0xe8
github.com/pion/turnc.(*Client).do(0x14850a0, 0x1490570, 0x1490540, 0x1ac504, 0x362b58)
        /root/go/src/github.com/pion/turnc/client.go:212 +0x80
github.com/pion/turnc.(*Client).allocate(0x14850a0, 0x1490570, 0x1490540, 0x4, 0x0, 0x0)
        /root/go/src/github.com/pion/turnc/client_allocation.go:44 +0x30
github.com/pion/turnc.(*Client).Allocate(0x14850a0, 0x1482570, 0x4037c0, 0x1485110)
        /root/go/src/github.com/pion/turnc/client_allocation.go:106 +0x164
github.com/pion/ice.(*Agent).gatherCandidatesRelay(0x1510120, 0x14e2378, 0x1, 0x2, 0x14e6828, 0x2)
        /root/go/src/github.com/pion/ice/gather.go:300 +0x1c8
github.com/pion/ice.(*Agent).gatherCandidates(0x1510120)
        /root/go/src/github.com/pion/ice/gather.go:136 +0x100
github.com/pion/ice.NewAgent(0x150bca0, 0x0, 0x0, 0x0)
        /root/go/src/github.com/pion/ice/agent.go:320 +0x6ac
github.com/pion/webrtc.(*ICEGatherer).createAgent(0x1528070, 0x0, 0x0)
        /root/go/src/github.com/pion/webrtc/icegatherer.go:113 +0x1bc
github.com/pion/webrtc.(*ICEGatherer).Gather(0x1528070, 0x14e8e30, 0x2800)
        /root/go/src/github.com/pion/webrtc/icegatherer.go:129 +0x1c
github.com/pion/webrtc.(*PeerConnection).SetRemoteDescription(0x14f0000, 0x1, 0x1556000, 0x187c, 0x0, 0x225c, 0x0)
        /root/go/src/github.com/pion/webrtc/peerconnection.go:865 +0xaac
main.gstreamerReceiveMain()
        /root/go/src/github.com/pion/example-webrtc-applications/gstreamer-receive/main.go:107 +0x3a8
created by main.main
        /root/go/src/github.com/pion/example-webrtc-applications/gstreamer-receive/main.go:139 +0x24
exit status 2

this error is caused at line https://github.com/pion/stun/blob/8e0ec0d856f6f92f80a604b6aef2b0c4191c9d48/client.go#L607

simple comment this line works, but I would like to know a better approach to solve this problem

some docs found https://golang.org/pkg/sync/atomic/#pkg-note-BUG https://github.com/ethereum/go-ethereum/issues/19590 https://github.com/golang/go/issues/9959