nyanmisaka / ffmpeg-rockchip

FFmpeg with async and zero-copy Rockchip MPP & RGA support
Other
325 stars 47 forks source link

Segmentation fault: mpp_buffer_group_init #56

Closed xaionaro closed 2 months ago

xaionaro commented 3 months ago

I'm running command:

ffmpeg -f v4l2 -input_format mjpeg -i /dev/video0 -c:v h264_rkmpp /tmp/1.flv

And it segfaults:

root@radxa-zero3:/dev/shm# ffmpeg -f v4l2 -input_format mjpeg -i /dev/video0 -c:v h264_rkmpp /tmp/1.flv
ffmpeg version ba84e56c51 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 10 (Debian 10.2.1-6)
  configuration: --prefix=/usr --enable-gpl --enable-version3 --enable-libdrm --enable-rkmpp --enable-rkrga
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 9571.528469, bitrate: N/A
  Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1000k tbn
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (h264_rkmpp))
Press [q] to stop, [?] for help
[swscaler @ 0xaaaaf7a9fd70] deprecated pixel format used, make sure you did set range correctly
Segmentation fault (core dumped)s

gdb says:

root@radxa-zero3:/dev/shm# gdb ffmpeg core
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ffmpeg...
(No debugging symbols found in ffmpeg)
[New LWP 32677]
[New LWP 32678]
[New LWP 32679]
[New LWP 32683]
[New LWP 32681]
[New LWP 32680]
[New LWP 32696]
[New LWP 32698]
[New LWP 32682]
[New LWP 32700]
[New LWP 32697]
[New LWP 32699]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".

warning: Loadable section ".note.gnu.build-id" outside of ELF segments
Core was generated by `ffmpeg -f v4l2 -input_format mjpeg -i /dev/video0 -c:v h264_rkmpp /tmp/1.flv'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000ffff842b4c0c in MppBufferService::get_group(char const*, char const*, MppBufferMode, MppBufferType, unsigned int) ()
   from /lib/aarch64-linux-gnu/librockchip_mpp.so.1
[Current thread is 1 (Thread 0xffff8072e010 (LWP 32677))]
(gdb) bt
#0  0x0000ffff842b4c0c in MppBufferService::get_group(char const*, char const*, MppBufferMode, MppBufferType, unsigned int) ()
   from /lib/aarch64-linux-gnu/librockchip_mpp.so.1
#1  0x0000ffff842b5040 in mpp_buffer_group_init () from /lib/aarch64-linux-gnu/librockchip_mpp.so.1
#2  0x0000aaaacdaeb318 in ?? ()
#3  0x0000aaaacdae9db8 in ?? ()
#4  0x0000aaaacd652d18 in ?? ()
#5  0x0000aaaacd34d690 in ?? ()
#6  0x0000aaaaccf6b438 in ?? ()
#7  0x0000aaaaccf6cc50 in ?? ()
#8  0x0000aaaaccf6e294 in ?? ()
#9  0x0000aaaaccf70bfc in ?? ()
#10 0x0000aaaaccf63350 in main ()
nyanmisaka commented 2 months ago

https://github.com/nyanmisaka/ffmpeg-rockchip#important

User MUST be granted permission to access these device files.


# DRM allocator
/dev/dri

DMA_HEAP allocator

/dev/dma_heap

RGA filters

/dev/rga

MPP codecs

/dev/mpp_service

Optional, for compatibility with older kernels and socs

/dev/iep /dev/mpp-service /dev/vpu_service /dev/vpu-service /dev/hevc_service /dev/hevc-service /dev/rkvdec /dev/rkvenc /dev/vepu /dev/h265e

xaionaro commented 2 months ago

ffmpeg was running under root and it had access to the devices.

nyanmisaka commented 2 months ago

Do not use the outdated MPP libs from Radxa.

https://github.com/nyanmisaka/ffmpeg-rockchip/issues/3#issuecomment-1875297620

xaionaro commented 2 months ago

Do not use the outdated MPP libs from Radxa.

Extremely humble opinion: it might make sense to put this requirement (which exactly version is required) somewhere. For example:

If somebody can tell which exactly minimum version is required then I can prepare a PR for README.md.

nyanmisaka commented 2 months ago

Sadly this doesn't prevent people from still trying to use outdated libraries because Rockchip never bumps version numbers in pkgconfig/rockchip_mpp.pc. The version checking during the configure stage of FFmpeg could have fundamentally avoided this problem, but Rockchip's approach makes this impossible.

Since I am not an employee of Rockchip, please report such issues to upstream and urge them to resolve them. Thanks.

xaionaro commented 2 months ago

Sadly this doesn't prevent people from still trying to use outdated libraries because Rockchip never bumps version numbers in pkgconfig/rockchip_mpp.pc. The version checking during the configure stage of FFmpeg could have fundamentally avoided this problem, but Rockchip's approach makes this impossible.

Since I am not an employee of Rockchip, please report such issues to upstream and urge them to resolve them. Thanks.

Done: https://github.com/rockchip-linux/mpp/commit/bcd3065dc9a8f915937efc17455f77b1e260ae3e

nyanmisaka commented 2 months ago

Sadly this doesn't prevent people from still trying to use outdated libraries because Rockchip never bumps version numbers in pkgconfig/rockchip_mpp.pc. The version checking during the configure stage of FFmpeg could have fundamentally avoided this problem, but Rockchip's approach makes this impossible. Since I am not an employee of Rockchip, please report such issues to upstream and urge them to resolve them. Thanks.

Done: rockchip-linux/mpp@bcd3065

I will use that in a future FFmpeg version. But for now it's too new for most distros and people will complain about this;)