go2rtc icon indicating copy to clipboard operation
go2rtc copied to clipboard

panic: runtime error: invalid memory address or nil pointer dereference

Open briney83 opened this issue 7 months ago • 7 comments

go2rtc version 1.9.9 linux/arm64 docker container

config:

api:
  password: *******
  username: *******
rtsp:
  password: *******
  username: *******
  
streams:
  vorota_hd_reg:
    - dvrip://*******@*******:34567?channel=0&subtype=0
  vorota_sd_reg:
    - dvrip://*******@*******:34567?channel=0&subtype=1
 
  smile_hd_reg:
    - dvrip://*******@*******:34567?channel=1&subtype=0
  smile_sd_reg:
    - dvrip://*******@*******:34567?channel=1&subtype=1
    

  vorota_hd:
    - dvrip://*******@*******:34567
  vorota_sd:
    - dvrip://*******@*******:34567?channel=0&subtype=1
    
  smile_hd:
    - dvrip://*******@*******:34567
  smile_sd:
    - dvrip://*******@*******:34567?channel=0&subtype=1
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]: panic: runtime error: invalid memory address or nil pointer dereference
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x265470]
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]: 
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]: goroutine 396 [running]:
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]: bufio.(*Writer).Flush(0x40006a80c0)
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]:         bufio/bufio.go:643 +0x40
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]: net/http.(*response).FlushError(0x4000914000)
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]:         net/http/server.go:1772 +0x38
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]: net/http.(*response).Flush(0x1d4c01010000?)
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]:         net/http/server.go:1765 +0x1c
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]: github.com/AlexxIT/go2rtc/pkg/core.(*WriteBuffer).Write(0x4000baa0c0, {0x4000524600?, 0x4000dfc090?, 0x400004aa08?})
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]:         github.com/AlexxIT/go2rtc/pkg/core/writebuffer.go:37 +0x1fc
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]: github.com/AlexxIT/go2rtc/pkg/mp4.(*Consumer).AddTrack.func1(0x40004c3728?)
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]:         github.com/AlexxIT/go2rtc/pkg/mp4/consumer.go:82 +0xf0
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]: github.com/AlexxIT/go2rtc/pkg/h264.RepairAVCC.func1(0x4000c90e01?)
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]:         github.com/AlexxIT/go2rtc/pkg/h264/avcc.go:22 +0x120
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]: github.com/AlexxIT/go2rtc/pkg/core.NewSender.func2(0x0?)
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]:         github.com/AlexxIT/go2rtc/pkg/core/track.go:112 +0x28
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]: github.com/AlexxIT/go2rtc/pkg/core.(*Sender).Start.func1()
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]:         github.com/AlexxIT/go2rtc/pkg/core/track.go:145 +0x48
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]: created by github.com/AlexxIT/go2rtc/pkg/core.(*Sender).Start in goroutine 394
мая 31 15:54:35 tinkerboard-2 c354fbac2d10[106820]:         github.com/AlexxIT/go2rtc/pkg/core/track.go:142 +0x134
мая 31 15:54:35 tinkerboard-2 systemd[1]: docker-c354fbac2d109afa9233ffaa156f31a1f2820aee5a75733dc2b91b42449a0c1a.scope: Deactivated successfully.
мая 31 15:54:35 tinkerboard-2 systemd[1]: docker-c354fbac2d109afa9233ffaa156f31a1f2820aee5a75733dc2b91b42449a0c1a.scope: Consumed 38.853s CPU time.
мая 31 15:54:35 tinkerboard-2 containerd[556]: time="2025-05-31T15:54:35.573163755+07:00" level=warning msg="cleaning up after shim disconnected" id=c354fbac2d109afa9233ffaa156f31a1f2820aee5a75733dc2b91b42449a0c1a namespace=moby
мая 31 15:54:35 tinkerboard-2 systemd[1]: mnt-dietpi_userdata-docker\x2ddata-overlay2-0b6161235d03182844d0a4880f9b791a93e7d417f137ad142b7be4f5819c943d-merged.mount: Deactivated successfully.
мая 31 15:54:36 tinkerboard-2 systemd[1]: Started docker-c354fbac2d109afa9233ffaa156f31a1f2820aee5a75733dc2b91b42449a0c1a.scope - libcontainer container c354fbac2d109afa9233ffaa156f31a1f2820aee5a75733dc2b91b42449a0c1a.
мая 31 15:54:36 tinkerboard-2 c354fbac2d10[106820]: 15:54:36.419 INF go2rtc platform=linux/arm64 revision=fa580c5 version=1.9.9
мая 31 15:54:36 tinkerboard-2 c354fbac2d10[106820]: 15:54:36.419 INF config path=/config/go2rtc.yaml
мая 31 15:54:36 tinkerboard-2 c354fbac2d10[106820]: 15:54:36.422 INF [api] listen addr=:1984
мая 31 15:54:36 tinkerboard-2 c354fbac2d10[106820]: 15:54:36.422 INF [rtsp] listen addr=:8554
мая 31 15:54:36 tinkerboard-2 c354fbac2d10[106820]: 15:54:36.427 INF [webrtc] listen addr=:8555

briney83 avatar May 31 '25 09:05 briney83

Thanks for the amazing project @AlexxIT!!

I think I'm experiencing the same or similar panic. I hope the following information helps.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x68b601]
goroutine 1451 [running]:
bufio.(*Writer).Write(0xc0009c6180, {0xc001eb6000?, 0x7f0986d80b48?, 0x0?})
        bufio/bufio.go:683 +0xe1
net/http.(*response).write(0xc0001501c0, 0xfd3d8, {0xc001eb6000, 0xfd3d8, 0xfd76c}, {0x0, 0x0})
        net/http/server.go:1702 +0x28d
net/http.(*response).Write(0xfd76c?, {0xc001eb6000?, 0x0?, 0xc001eb6000?})
        net/http/server.go:1665 +0x2a
github.com/AlexxIT/go2rtc/pkg/core.(*WriteBuffer).Write(0xc0009c61c0, {0xc001eb6000?, 0xc0003cbd40?, 0xc000863ee0?})
        github.com/AlexxIT/go2rtc/pkg/core/writebuffer.go:33 +0x92
github.com/AlexxIT/go2rtc/pkg/mp4.(*Consumer).AddTrack.func1(0xc000e00000?)
        github.com/AlexxIT/go2rtc/pkg/mp4/consumer.go:82 +0xae
github.com/AlexxIT/go2rtc/pkg/h264.RTPDepay.func1(0xc0003cbcb0)
        github.com/AlexxIT/go2rtc/pkg/h264/rtp.go:103 +0x39b
github.com/AlexxIT/go2rtc/pkg/core.NewSender.func2(0xc0003cd170?)
        github.com/AlexxIT/go2rtc/pkg/core/track.go:112 +0x1b
github.com/AlexxIT/go2rtc/pkg/core.(*Sender).Start.func1()
        github.com/AlexxIT/go2rtc/pkg/core/track.go:145 +0x47
created by github.com/AlexxIT/go2rtc/pkg/core.(*Sender).Start in goroutine 1449
        github.com/AlexxIT/go2rtc/pkg/core/track.go:142 +0xf9
api:
  listen: :1984
  origin: '*'
ffmpeg:
  bin: /nix/store/7v6a47qh8p84bgds916jlmm6ayvd1n4m-ffmpeg-headless-7.1.1-bin/bin/ffmpeg
rtsp: {}
streams:
  front:
  - onvif://********:8000?subtype=000
  - ffmpeg:front#audio=opus
  front_sub:
  - onvif://********:8000?subtype=001
  - ffmpeg:front#audio=opus
webrtc:
  candidates:
  - 10.100.0.1:8555
  - stun:8555
  listen: :8555

jackinloadup avatar Jul 13 '25 03:07 jackinloadup

same exact here, it seems to happen most often when go2rtc is started during boot. I added a sleep time of 15 seconds to my start script before launching go2rtc, and it seems to not happen anymore. I also seemed to have gotten the same crash on 1.9.8, but not on launch - about 40 days into running

00:34:47.760 INF go2rtc platform=linux/amd64 revision=fa580c5 version=1.9.9
00:34:47.760 INF config path=/root/go2rtc/go2rtc.yaml
00:34:47.761 ERR [api] listen error="listen tcp :1984: bind: address already in use"
00:34:47.761 ERR [rtsp] listen error="listen tcp :8554: bind: address already in use"
00:34:47.761 INF [webrtc] listen addr=:8555
00:38:54.908 INF go2rtc platform=linux/amd64 revision=fa580c5 version=1.9.9
00:38:54.908 INF config path=/root/go2rtc/go2rtc.yaml
00:38:54.909 ERR [rtsp] listen error="listen tcp :8554: bind: address already in use"
00:38:54.909 ERR [api] listen error="listen tcp :1984: bind: address already in use"
00:38:54.909 INF [webrtc] listen addr=:8555
00:39:38.245 INF go2rtc platform=linux/amd64 revision=fa580c5 version=1.9.9
00:39:38.245 INF config path=/root/go2rtc/go2rtc.yaml
00:39:38.246 INF [rtsp] listen addr=:8554
00:39:38.246 INF [webrtc] listen addr=:8555
00:39:38.247 INF [api] listen addr=:1984
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x978d98]

goroutine 136 [running]:
github.com/pion/ice/v2.(*MultiUDPMuxDefault).RemoveConnByUfrag(0xc0001e0cc0?, {0x0, 0x0})
        github.com/pion/ice/[email protected]/udp_mux_multi.go:51 +0x18
github.com/pion/ice/v2.(*Agent).removeUfragFromMux(0xc0008ccf08)
        github.com/pion/ice/[email protected]/agent.go:914 +0x72
github.com/pion/ice/v2.(*Agent).Restart.func1({0xc0008a0f58?, 0xc0008a0f30?}, 0xc0008ccf08)
        github.com/pion/ice/[email protected]/agent.go:1267 +0x65
github.com/pion/ice/v2.(*Agent).taskLoop(0xc0008ccf08)
        github.com/pion/ice/[email protected]/agent.go:246 +0x11a
created by github.com/pion/ice/v2.NewAgent in goroutine 13
        github.com/pion/ice/[email protected]/agent.go:375 +0xdd9

Fohdeesha avatar Jul 25 '25 05:07 Fohdeesha

@Fohdeesha your panic from another issue

AlexxIT avatar Jul 25 '25 13:07 AlexxIT

@AlexxIT interesting, how can you tell, the slightly different address for the violation? Is there a relevant github issue for mine?

Fohdeesha avatar Jul 25 '25 21:07 Fohdeesha

This issue about bufio.(*Writer).Flush panic. Your issue about v2.(*MultiUDPMuxDefault).RemoveConnByUfrag panic.

AlexxIT avatar Jul 26 '25 08:07 AlexxIT

I have this panic too

go2rtc  | panic: runtime error: invalid memory address or nil pointer dereference
go2rtc  | [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x66cec1]
go2rtc  | 
go2rtc  | goroutine 648 [running]:
go2rtc  | bufio.(*Writer).Write(0xc000240a40, {0xc000690000?, 0x60063?, 0xc000350d40?})
go2rtc  | 	bufio/bufio.go:683 +0xe1
go2rtc  | net/http.(*response).write(0xc00046e000, 0x16ab, {0xc000690000, 0x16ab, 0x1a3f}, {0x0, 0x0})
go2rtc  | 	net/http/server.go:1702 +0x28d
go2rtc  | net/http.(*response).Write(0x1a3f?, {0xc000690000?, 0x0?, 0xc000690000?})
go2rtc  | 	net/http/server.go:1665 +0x2a
go2rtc  | github.com/AlexxIT/go2rtc/pkg/core.(*WriteBuffer).Write(0xc000240ac0, {0xc000690000?, 0xc000387830?, 0x41a13d?})
go2rtc  | 	github.com/AlexxIT/go2rtc/pkg/core/writebuffer.go:33 +0x92
go2rtc  | github.com/AlexxIT/go2rtc/pkg/mp4.(*Consumer).AddTrack.func1(0xc000033110?)
go2rtc  | 	github.com/AlexxIT/go2rtc/pkg/mp4/consumer.go:82 +0xae
go2rtc  | github.com/AlexxIT/go2rtc/pkg/h264.RTPDepay.func1(0xc000387560)
go2rtc  | 	github.com/AlexxIT/go2rtc/pkg/h264/rtp.go:103 +0x383
go2rtc  | github.com/AlexxIT/go2rtc/pkg/core.NewSender.func2(0xc00051b5f0?)
go2rtc  | 	github.com/AlexxIT/go2rtc/pkg/core/track.go:112 +0x1b
go2rtc  | github.com/AlexxIT/go2rtc/pkg/core.(*Sender).Start.func1(0xc0002a01c0)
go2rtc  | 	github.com/AlexxIT/go2rtc/pkg/core/track.go:145 +0x43
go2rtc  | created by github.com/AlexxIT/go2rtc/pkg/core.(*Sender).Start in goroutine 646
go2rtc  | 	github.com/AlexxIT/go2rtc/pkg/core/track.go:143 +0x151

devil666face avatar Sep 05 '25 11:09 devil666face

@AlexxIT у меня тоже встречается такая ошибка(

go2rtc  | panic: runtime error: invalid memory address or nil pointer dereference
go2rtc  | [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x66cec1]
go2rtc  | 
go2rtc  | goroutine 648 [running]:
go2rtc  | bufio.(*Writer).Write(0xc000240a40, {0xc000690000?, 0x60063?, 0xc000350d40?})
go2rtc  | 	bufio/bufio.go:683 +0xe1
go2rtc  | net/http.(*response).write(0xc00046e000, 0x16ab, {0xc000690000, 0x16ab, 0x1a3f}, {0x0, 0x0})
go2rtc  | 	net/http/server.go:1702 +0x28d
go2rtc  | net/http.(*response).Write(0x1a3f?, {0xc000690000?, 0x0?, 0xc000690000?})
go2rtc  | 	net/http/server.go:1665 +0x2a
go2rtc  | github.com/AlexxIT/go2rtc/pkg/core.(*WriteBuffer).Write(0xc000240ac0, {0xc000690000?, 0xc000387830?, 0x41a13d?})
go2rtc  | 	github.com/AlexxIT/go2rtc/pkg/core/writebuffer.go:33 +0x92
go2rtc  | github.com/AlexxIT/go2rtc/pkg/mp4.(*Consumer).AddTrack.func1(0xc000033110?)
go2rtc  | 	github.com/AlexxIT/go2rtc/pkg/mp4/consumer.go:82 +0xae
go2rtc  | github.com/AlexxIT/go2rtc/pkg/h264.RTPDepay.func1(0xc000387560)
go2rtc  | 	github.com/AlexxIT/go2rtc/pkg/h264/rtp.go:103 +0x383
go2rtc  | github.com/AlexxIT/go2rtc/pkg/core.NewSender.func2(0xc00051b5f0?)
go2rtc  | 	github.com/AlexxIT/go2rtc/pkg/core/track.go:112 +0x1b
go2rtc  | github.com/AlexxIT/go2rtc/pkg/core.(*Sender).Start.func1(0xc0002a01c0)
go2rtc  | 	github.com/AlexxIT/go2rtc/pkg/core/track.go:145 +0x43
go2rtc  | created by github.com/AlexxIT/go2rtc/pkg/core.(*Sender).Start in goroutine 646
go2rtc  | 	github.com/AlexxIT/go2rtc/pkg/core/track.go:143 +0x151

3ayazaya avatar Sep 09 '25 08:09 3ayazaya