Segment violation in `libnvcuvid.so.1`
- Dominant language
- Go
- Stars
- 283
- Forks
- 72
- Avg merge
- 27m
- Merged PRs (30d)
- 1
Description
When `go-livepeer` is under heavy load and there is constantly not enough video memory, node often panic's with `Segmentation fault`.
Stack trace:
```
#0 0x00007fff8415d7e0 in ?? () from /usr/lib/x86_64-linux-gnu/libnvcuvid.so.1
#1 0x00007fff8415d952 in ?? () from /usr/lib/x86_64-linux-gnu/libnvcuvid.so.1
#2 0x00007fff8415d9ea in ?? () from /usr/lib/x86_64-linux-gnu/libnvcuvid.so.1
#3 0x00007fff841147c6 in ?? () from /usr/lib/x86_64-linux-gnu/libnvcuvid.so.1
#4 0x00007fff8412974b in ?? () from /usr/lib/x86_64-linux-gnu/libnvcuvid.so.1
#5 0x00007fff8410d665 in ?? () from /usr/lib/x86_64-linux-gnu/libnvcuvid.so.1
#6 0x00007fff381e70f3 in ?? () from /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1
#7 0x00007fff381e26da in ?? () from /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1
#8 0x00007fff381f1499 in ?? () from /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1
#9 0x0000000000496c75 in nvenc_setup_encoder (avctx=avctx@entry=0x7fffcc43cc40) at libavcodec/nvenc.c:1259
#10 0x0000000000498758 in ff_nvenc_encode_init (avctx=0x7fffcc43cc40) at libavcodec/nvenc.c:1553
#11 0x00000000013cd05c in avcodec_open2 (avctx=avctx@entry=0x7fffcc43cc40, codec=codec@entry=0x2c06740 , options=0xc008cde1d0) at libavcodec/utils.c:951
#12 0x0000000000fd4200 in open_output (ictx=0x7fffe8001598, octx=0x7fffe80015f8) at lpms_ffmpeg.c:693
#13 transcode (h=h@entry=0x7fffe8001590, inp=inp@entry=0xc00000ff60, params=params@entry=0xc008cde180, results=results@entry=0xc0000c2410, decoded_results=decoded_results@entry=0xc0000c2440) at lpms_ffmpeg.c:1145
#14 0x0000000000fd4d68 in lpms_transcode (inp=0xc00000ff60, params=0xc008cde180, results=0xc0000c2410, nb_outputs=1, decoded_results=0xc0000c2440) at lpms_ffmpeg.c:1308
#15 0x0000000000fd1376 in _cgo_f32e5de116c8_Cfunc_lpms_transcode (v=0xc000079938) at cgo-gcc-prolog:140
#16 0x00000000004fedd0 in runtime.asmcgocall () at /usr/lib/go-1.13/src/runtime/asm_amd64.s:655
#17 0x0000000000000040 in ?? ()
#18 0x0000000001c32e80 in type.* ()
#19 0x00000000004fb401 in runtime.(*mheap).setSpan (h=, base=0, s=0xc000079938) at /usr/lib/go-1.13/src/runtime/mheap.go:1143
#20 runtime.(*mheap).scavengeSplit.func1 (s=0x4d3600 ) at /usr/lib/go-1.13/src/runtime/mheap.go:1459
#21 0x000000c0002f1980 in ?? ()
#22 0x00000000004d3600 in ?? () at /usr/lib/go-1.13/src/runtime/proc.go:1080
#23 0x0000000000000000 in ?? ()
```
`nvenc.c:1259` is:
```c
nv_status = p_nvenc->nvEncInitializeEncoder(ctx->nvencoder, &ctx->init_encode_params);
```
[stack_with_variable.txt](https://github.com/livepeer/lpms/files/4130895/stack_with_variable.txt)
I think it is either of:
- We're not processing some errors correctly and as a result passing some invalid data down to Nvidia drivers and that leads to segmental fault
- Ffmpeg's code not processing errors correctly and passes invalid data to drivers
- Just bug in Nvidia's code
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with libavcodec/nvenc.c:1259 and the open_output and transcode paths in lpms_ffmpeg.c cited by the stack trace. Reproduce go-livepeer under heavy load with insufficient video memory, then trace the error handling around encoder initialization; done means identifying and fixing the invalid-data path or establishing that the fault is in the NVIDIA driver.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, go
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100