Skip to content

V4L2 oops when transcoding with Jellyfin #4920

Open

Description

@dfunkt

Describe the bug

Sometimes when I try to play something that requires transcoding it just hangs infinitely and the info attached in the logs below pops up in dmesg.

Steps to reproduce the behaviour

Try to transcode content in Jellyfin (nightly version) with the V4L2 encoder.

Device (s)

Raspberry Pi 4 Mod. B

System

cat /etc/rpi-issue:
Raspberry Pi reference 2022-01-28
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, fbe448ccdc995d295d24c7596e5f0ef62cc2488f, stage2

vcgencmd version:
Jan 20 2022 13:56:48
Copyright (c) 2012 Broadcom
version bd88f66f8952d34e4e0613a85c7a6d3da49e13e2 (clean) (release) (start)

uname -a:
Linux raspberrypi 5.10.92-v8+ #1514 SMP PREEMPT Mon Jan 17 17:39:38 GMT 2022 aarch64 GNU/Linux

Logs

[29319.203001] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
[29319.211821] Mem abort info:
[29319.214835]   ESR = 0x96000045
[29319.217906]   EC = 0x25: DABT (current EL), IL = 32 bits
[29319.223491]   SET = 0, FnV = 0
[29319.226581]   EA = 0, S1PTW = 0
[29319.229731] Data abort info:
[29319.232690]   ISV = 0, ISS = 0x00000045
[29319.236637]   CM = 0, WnR = 1
[29319.239679] user pgtable: 4k pages, 39-bit VAs, pgdp=00000000b9962000
[29319.246141] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000
[29319.254863] Internal error: Oops: 96000045 [#1] PREEMPT SMP
[29319.260433] Modules linked in: xt_nat xt_tcpudp veth xt_conntrack xt_MASQUERADE nf_conntrack_netlink xt_addrtype nft_compat br_netfilter bridge nft_masq nft_counter nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nf_tables nfnetlink wireguard libchacha20poly1305 chacha_neon poly1305_neon ip6_udp_tunnel udp_tunnel libcurve25519_generic libblake2s libblake2s_generic libchacha overlay cfg80211 rfkill 8021q garp stp llc snd_soc_hdmi_codec vc4 cec v3d bcm2835_v4l2(C) drm_kms_helper gpu_sched videobuf2_vmalloc raspberrypi_hwmon bcm2835_codec(C) bcm2835_isp(C) v4l2_mem2mem bcm2835_mmal_vchiq(C) videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videobuf2_common snd_soc_core snd_bcm2835(C) snd_compress snd_pcm_dmaengine snd_pcm i2c_brcmstb videodev snd_timer mc syscopyarea sysfillrect vc_sm_cma(C) snd sysimgblt fb_sys_fops rpivid_mem nvmem_rmem uio_pdrv_genirq uio aes_neon_bs aes_neon_blk crypto_simd cryptd drm fuse drm_panel_orientation_quirks backlight ip_tables x_tables ipv6
[29319.348081] CPU: 1 PID: 68476 Comm: ffmpeg Tainted: G         C        5.10.92-v8+ #1514
[29319.356166] Hardware name: Raspberry Pi 4 Model B Rev 1.2 (DT)
[29319.361994] pstate: 20000005 (nzCv daif -PAN -UAO -TCO BTYPE=--)
[29319.368005] pc : vchiq_mmal_port_enable+0xd8/0x158 [bcm2835_mmal_vchiq]
[29319.374615] lr : vchiq_mmal_port_enable+0x114/0x158 [bcm2835_mmal_vchiq]
[29319.381309] sp : ffffffc0129dba80
[29319.384616] x29: ffffffc0129dba80 x28: 0000000000000002
[29319.389925] x27: dead000000000100 x26: dead000000000122
[29319.395232] x25: ffffff8046800220 x24: ffffff8046800008
[29319.400540] x23: ffffff8046800000 x22: ffffff8046800178
[29319.405849] x21: 0000000000000000 x20: 0000000000000000
[29319.411156] x19: ffffff8048256918 x18: 0000000000000011
[29319.416462] x17: 0000000000000000 x16: 0000000000000000
[29319.421769] x15: ffffffffffffffff x14: ffffffc010e1d178
[29319.427076] x13: ffffffc0929db7f7 x12: ffffffc0129db7fd
[29319.432383] x11: bcbcbcbcbcbcbcbc x10: ffffffc0129db7b0
[29319.437690] x9 : ffffffc0108f8a04 x8 : 00000000000000c9
[29319.442997] x7 : 0000000000000002 x6 : ffffffc0129db700
[29319.448304] x5 : 0000000000000000 x4 : 0000000000000001
[29319.453610] x3 : ffffff80462cd01c x2 : 5b4b840ceead0300
[29319.458917] x1 : 0000000000000000 x0 : 0000000000000000
[29319.464224] Call trace:
[29319.466669]  vchiq_mmal_port_enable+0xd8/0x158 [bcm2835_mmal_vchiq]
[29319.472934]  bcm2835_codec_start_streaming+0x214/0x408 [bcm2835_codec]
[29319.479460]  vb2_start_streaming+0x74/0x160 [videobuf2_common]
[29319.485290]  vb2_core_streamon+0x98/0x198 [videobuf2_common]
[29319.490946]  vb2_streamon+0x24/0x78 [videobuf2_v4l2]
[29319.495909]  v4l2_m2m_streamon+0x34/0x88 [v4l2_mem2mem]
[29319.501130]  v4l2_m2m_ioctl_streamon+0x20/0x30 [v4l2_mem2mem]
[29319.506895]  v4l_streamon+0x2c/0x38 [videodev]
[29319.511345]  __video_do_ioctl+0x18c/0x3f0 [videodev]
[29319.516317]  video_usercopy+0x154/0x618 [videodev]
[29319.521115]  video_ioctl2+0x20/0x68 [videodev]
[29319.525565]  v4l2_ioctl+0x48/0x68 [videodev]
[29319.529834]  __arm64_sys_ioctl+0xb0/0xf0
[29319.533751]  el0_svc_common.constprop.3+0xc0/0x1f8
[29319.538535]  do_el0_svc+0x2c/0x98
[29319.541843]  el0_svc+0x20/0x30
[29319.544890]  el0_sync_handler+0x90/0xb8
[29319.548719]  el0_sync+0x180/0x1c0
[29319.552030] Code: f2fbd5bb f2fbd5ba 1400000c a9400261 (f9000420)
[29319.558118] ---[ end trace a323116043d22061 ]---
[29344.094867] bcm2835-codec bcm2835-codec: Mutex fail

Activity

  1. chuma9615 commented on Aug 9, 2022

    @chuma9615

    Any update on this? We've been having this exact same crash consistently while hardware encoding a live RSTP input

  2. chuma9615 commented on Aug 9, 2022

    @chuma9615

    Describe the bug

    Sometimes when encoding a livestream using ffmpeg the hardware encoder fails, leaving the ISP unusable, one can actually copy the stream after the crash but not re-use the hardware encoder unless rebooting the system

    Steps to reproduce the behaviour

    Hardware encode a RSTP stream using h264_v4l2m2m encoder

    Command
    ffmpeg -rtsp_transport tcp -nostdin -fflags +igndts -use_wallclock_as_timestamps 1 -r 12.5 -flags +global_header -y -i rtsp://192.0.2.3/stream/jpeg -vf scale=-1:720,showinfo -c:v h264_v4l2m2m -copytb 0 -copyts -num_output_buffers 32 -num_capture_buffers 16 -pix_fmt yuv420p -f mpegts -movflags faststart -b:v 3M -fps_mode passthrough -segment_time 600 -reset_timestamps 1 -f segment -strftime 1 -segment_format mpegts -segment_atclocktime 1 /home/pi/output/videos/%Y%m%d_%H%M%S_600.ts

    Device (s)

    Raspberry Pi CM4 4GB RAM

    System

    cat /etc/rpi-issue:
    Raspberry Pi reference 2022-04-04
    Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 27a8050c3c06e567c794620394a8c2d74262a516, stage4
    
    vcgencmd version:
    Mar 24 2022 13:19:26 
    Copyright (c) 2012 Broadcom
    version e5a963efa66a1974127860b42e913d2374139ff5 (clean) (release) (start)
    
    uname -a:
    Linux C9 5.15.32-v8+ #1538 SMP PREEMPT Thu Mar 31 19:40:39 BST 2022 aarch64 GNU/Linux
    

    Logs

    Aug  9 10:01:52 C9 kernel: [18705.248875] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
    Aug  9 10:01:52 C9 kernel: [18705.248901] Mem abort info:
    Aug  9 10:01:52 C9 kernel: [18705.248907]   ESR = 0x96000045
    Aug  9 10:01:52 C9 kernel: [18705.248914]   EC = 0x25: DABT (current EL), IL = 32 bits
    Aug  9 10:01:52 C9 kernel: [18705.248957]   SET = 0, FnV = 0
    Aug  9 10:01:52 C9 kernel: [18705.248964]   EA = 0, S1PTW = 0
    Aug  9 10:01:52 C9 kernel: [18705.248970]   FSC = 0x05: level 1 translation fault
    Aug  9 10:01:52 C9 kernel: [18705.248976] Data abort info:
    Aug  9 10:01:52 C9 kernel: [18705.248981]   ISV = 0, ISS = 0x00000045
    Aug  9 10:01:52 C9 kernel: [18705.248987]   CM = 0, WnR = 1
    Aug  9 10:01:52 C9 kernel: [18705.248993] user pgtable: 4k pages, 39-bit VAs, pgdp=0000000092a48000
    Aug  9 10:01:52 C9 kernel: [18705.249001] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000
    Aug  9 10:01:52 C9 kernel: [18705.249022] Internal error: Oops: 96000045 [#1] PREEMPT SMP
    Aug  9 10:01:52 C9 kernel: [18705.249029] Modules linked in: cdc_ether qmi_wwan cdc_wdm option usb_wwan 8021q garp stp llc emc2301(O) binfmt_misc brcmfmac brcmutil ftdi_sio usbserial cfg80211 rfkill snd_bcm2835(C) i2c_mux_pinctrl bcm2835_codec(C) i2c_mux v4l2_mem2mem bcm2835_v4l2(C) bcm2835_isp(C) videobuf2_dma_contig bcm2835_mmal_vchiq(C) videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 snd_pcm videobuf2_common raspberrypi_hwmon snd_timer videodev vc_sm_cma(C) snd mc i2c_bcm2835 w1_therm rpivid_mem w1_gpio wire cn uio_pdrv_genirq uio nvmem_rmem i2c_dev fuse drm drm_panel_orientation_quirks backlight ip_tables x_tables ipv6
    Aug  9 10:01:52 C9 kernel: [18705.249142] CPU: 1 PID: 16509 Comm: ffmpeg Tainted: G         C O      5.15.32-v8+ #1538
    Aug  9 10:01:52 C9 kernel: [18705.249150] Hardware name: Raspberry Pi Compute Module 4 Rev 1.0 (DT)
    Aug  9 10:01:52 C9 kernel: [18705.249155] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    Aug  9 10:01:52 C9 kernel: [18705.249161] pc : vchiq_mmal_port_enable+0xd8/0x158 [bcm2835_mmal_vchiq]
    Aug  9 10:01:52 C9 kernel: [18705.249178] lr : vchiq_mmal_port_enable+0x114/0x158 [bcm2835_mmal_vchiq]
    Aug  9 10:01:52 C9 kernel: [18705.249187] sp : ffffffc00e0cba60
    Aug  9 10:01:52 C9 kernel: [18705.249190] x29: ffffffc00e0cba60 x28: 0000000000000002 x27: dead000000000100
    Aug  9 10:01:52 C9 kernel: [18705.249201] x26: dead000000000122 x25: ffffff804cdc0220 x24: ffffff804cdc0008
    Aug  9 10:01:52 C9 kernel: [18705.249210] x23: ffffff804cdc0000 x22: ffffff804cdc0178 x21: 0000000000000000
    Aug  9 10:01:52 C9 kernel: [18705.249219] x20: 0000000000000000 x19: ffffff8092090918 x18: 0000000000000011
    Aug  9 10:01:52 C9 kernel: [18705.249228] x17: 0000000000000000 x16: 0000000000000000 x15: ffffffffffffffff
    Aug  9 10:01:52 C9 kernel: [18705.249236] x14: ffffffc008e8a9c8 x13: ffffffc08e0cb7d7 x12: ffffffc00e0cb7dd
    Aug  9 10:01:52 C9 kernel: [18705.249245] x11: bcbcbcbcbcbcbcbc x10: 000000000000003a x9 : ffffffc00892654c
    Aug  9 10:01:52 C9 kernel: [18705.249254] x8 : 00000000000000aa x7 : 0000000000000002 x6 : ffffffc00e0cb6e0
    Aug  9 10:01:52 C9 kernel: [18705.249263] x5 : 0000000000000000 x4 : 0000000000000001 x3 : ffffff8045ca701c
    Aug  9 10:01:52 C9 kernel: [18705.249271] x2 : 99d17e1a4f890200 x1 : 0000000000000000 x0 : 0000000000000000
    Aug  9 10:01:52 C9 kernel: [18705.249280] Call trace:
    Aug  9 10:01:52 C9 kernel: [18705.249283]  vchiq_mmal_port_enable+0xd8/0x158 [bcm2835_mmal_vchiq]
    Aug  9 10:01:52 C9 kernel: [18705.249293]  bcm2835_codec_start_streaming+0x214/0x408 [bcm2835_codec]
    Aug  9 10:01:52 C9 kernel: [18705.249303]  vb2_start_streaming+0x74/0x160 [videobuf2_common]
    Aug  9 10:01:52 C9 kernel: [18705.249319]  vb2_core_streamon+0x98/0x198 [videobuf2_common]
    Aug  9 10:01:52 C9 kernel: [18705.249331]  vb2_streamon+0x24/0x78 [videobuf2_v4l2]
    Aug  9 10:01:52 C9 kernel: [18705.249342]  v4l2_m2m_streamon+0x34/0x88 [v4l2_mem2mem]
    Aug  9 10:01:52 C9 kernel: [18705.249355]  v4l2_m2m_ioctl_streamon+0x20/0x30 [v4l2_mem2mem]
    Aug  9 10:01:52 C9 kernel: [18705.249366]  v4l_streamon+0x2c/0x38 [videodev]
    Aug  9 10:01:52 C9 kernel: [18705.249403]  __video_do_ioctl+0x188/0x410 [videodev]
    Aug  9 10:01:52 C9 kernel: [18705.249434]  video_usercopy+0x310/0x7d0 [videodev]
    Aug  9 10:01:52 C9 kernel: [18705.249464]  video_ioctl2+0x20/0x38 [videodev]
    Aug  9 10:01:52 C9 kernel: [18705.249495]  v4l2_ioctl+0x48/0x68 [videodev]
    Aug  9 10:01:52 C9 kernel: [18705.249525]  __arm64_sys_ioctl+0xb0/0xf0
    Aug  9 10:01:52 C9 kernel: [18705.249534]  invoke_syscall+0x4c/0x110
    Aug  9 10:01:52 C9 kernel: [18705.249543]  el0_svc_common.constprop.3+0xfc/0x120
    Aug  9 10:01:52 C9 kernel: [18705.249549]  do_el0_svc+0x2c/0x90
    Aug  9 10:01:52 C9 kernel: [18705.249555]  el0_svc+0x24/0x60
    Aug  9 10:01:52 C9 kernel: [18705.249563]  el0t_64_sync_handler+0x90/0xb8
    Aug  9 10:01:52 C9 kernel: [18705.249569]  el0t_64_sync+0x1a0/0x1a4
    Aug  9 10:01:52 C9 kernel: [18705.249577] Code: f2fbd5bb f2fbd5ba 1400000c a9400261 (f9000420) 
    Aug  9 10:01:52 C9 kernel: [18705.249583] ---[ end trace 467d91e1301520a6 ]---
    
  3. roger- commented on Nov 16, 2022

    @roger-

    Experiencing the same issue when the encoder runs for multiple days (unrelated to Jellyfin).

    ffmpeg doesn't give any errors, just freezes and I see this in dmesg:

    [321584.070481] bcm2835-codec bcm2835-codec: Mutex fail
    
  4. TubaApollo commented on Nov 19, 2022

    @TubaApollo

    Same issue here, seems to be especially an issue when seeking fast for me
    (Raspberry Pi 4 Model B Rev 1.4 (DT))

  5. huelsenfruchtzwerg commented on Dec 1, 2022

    @huelsenfruchtzwerg

    Same issue here

  6. shmuelzon commented on Apr 21, 2023

    @shmuelzon

    Still seeing the same on RPi 3 with kernel version:
    Linux raspberrypi 6.1.21-v7+ #1642 SMP Mon Apr 3 17:20:52 BST 2023 armv7l GNU/Linux
    Using the encoder from time to time for a few minutes and at some point it just stops working with the following crash dump:

    [133329.621107] Unable to handle kernel NULL pointer dereference at virtual address 00000004
    [133329.625135] [00000004] *pgd=00000000
    [133329.627097] Internal error: Oops: 805 [#1] SMP ARM
    [133329.628896] Modules linked in: xt_conntrack xt_MASQUERADE nf_conntrack_netlink nfnetlink iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 xt_addrtype iptable_filter br_netfilter bridge cmac algif_hash aes_arm_bs crypto_simd cryptd algif_skcipher af_alg bnep hci_uart btbcm bluetooth ecdh_generic ecc overlay 8021q garp stp llc brcmfmac it913x af9033 regmap_i2c brcmutil sha256_generic cfg80211 dvb_usb_af9035 dvb_usb_v2 dvb_core bcm2835_codec(C) bcm2835_v4l2(C) videobuf2_vmalloc v4l2_mem2mem rfkill bcm2835_isp(C) bcm2835_mmal_vchiq(C) videobuf2_dma_contig snd_bcm2835(C) videobuf2_memops videobuf2_v4l2 videobuf2_common raspberrypi_hwmon snd_pcm videodev snd_timer snd vc_sm_cma(C) mc uio_pdrv_genirq uio fixed drm fuse drm_panel_orientation_quirks backlight ip_tables x_tables ipv6
    [133329.648879] CPU: 0 PID: 23115 Comm: ffmpeg Tainted: G         C         6.1.21-v7+ #1642
    [133329.653402] Hardware name: BCM2835
    [133329.655683] PC is at vchiq_mmal_port_enable+0xcc/0x108 [bcm2835_mmal_vchiq]
    [133329.658135] LR is at vchiq_release_service+0x30/0x40
    [133329.660533] pc : [<7f1ba64c>]    lr : [<80857f50>]    psr: 60000013
    [133329.662955] sp : bc24dd60  ip : 00000000  fp : 00000002
    [133329.665320] r10: 00000000  r9 : 85c00194  r8 : 85c00004
    [133329.667617] r7 : 85c00000  r6 : 85c0010c  r5 : 00000000  r4 : 8415b620
    [133329.669935] r3 : 04195133  r2 : 00000000  r1 : 00000000  r0 : 00000100
    [133329.672243] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
    [133329.674569] Control: 10c5383d  Table: 29e9006a  DAC: 00000055
    [133329.676843] Register r0 information: non-paged memory
    [133329.679072] Register r1 information: NULL pointer
    [133329.681202] Register r2 information: NULL pointer
    [133329.683217] Register r3 information: non-paged memory
    [133329.685147] Register r4 information: slab kmalloc-4k start 8415b000 pointer offset 1568 size 4096
    [133329.688882] Register r5 information: NULL pointer
    [133329.690721] Register r6 information: non-slab/vmalloc memory
    [133329.692504] Register r7 information: non-slab/vmalloc memory
    [133329.694186] Register r8 information: non-slab/vmalloc memory
    [133329.695776] Register r9 information: non-slab/vmalloc memory
    [133329.697317] Register r10 information: NULL pointer
    [133329.698801] Register r11 information: non-paged memory
    [133329.700242] Register r12 information: NULL pointer
    [133329.701625] Process ffmpeg (pid: 23115, stack limit = 0x74a0cb71)
    [133329.703031] Stack: (0xbc24dd60 to 0xbc24e000)
    [133329.704441] dd60: 00000000 85c0010c 00000002 8415b000 00000000 7f25c300 a9c90178 852a4840
    [133329.707387] dd80: 8415b0e8 7f256f74 81005008 7e91616c bc24de74 00000011 40045612 a9c90130
    [133329.710446] dda0: a9c90278 a9c90178 7f1d8f2c 00000001 852a4b50 7f25990c 85037180 7f2a30e4
    [133329.713696] ddc0: a9c90178 a9c90000 81005008 7f1d8f2c 00000001 7f2a3744 0000000a 7f2e2ae8
    [133329.717352] dde0: 852a48a0 40045612 81005008 7f1ddd54 00000000 00000000 8415b000 00000000
    [133329.721203] de00: 00000000 bc24de74 00000001 7f1f3ce8 81005008 20000013 b6b304d4 20000013
    [133329.725217] de20: 811d9274 04195133 b7117610 40045612 40045612 81005008 00000009 bc24de74
    [133329.729659] de40: 00000000 7e916108 00000000 7f1de814 bc24de73 b7117610 85037180 7f1ddb2c
    [133329.734500] de60: 00000000 00000000 00000000 00000000 00e2d1d8 0000000a 00000000 00000000
    [133329.739667] de80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000254
    [133329.745035] dea0: 75c49000 81005008 00000000 00000040 bc24dfb0 bc24deec 000001d8 80309f64
    [133329.750481] dec0: bc24df70 81005008 a6c95840 80353e88 81005008 000001e7 a6ca1800 80b7af8c
    [133329.755923] dee0: 82414600 80109c4c bc24df40 a9e0d870 00100cca 04195133 75c49000 40045612
    [133329.761375] df00: 81005008 00000000 00000009 85037181 85037180 7e916108 830bac50 8036b880
    [133329.766830] df20: 00000036 40000028 76f0235a 00000000 00000009 00000000 40045612 00000000
    [133329.772285] df40: 7e916108 00000000 7e916108 00000000 40045612 00000000 734ef900 00000000
    [133329.777742] df60: 81005008 04195133 00000007 87b3b600 bc24dfb0 734ef900 00000036 04195133
    [133329.783203] df80: 87b3b600 40045612 734ef900 734ef900 00000036 80100264 87b3b600 00000036
    [133329.788663] dfa0: 00000000 80100254 40045612 734ef900 00000009 40045612 7e916108 7e916108
    [133329.794120] dfc0: 40045612 734ef900 734ef900 00000036 00000009 734b2880 734ef800 00000000
    [133329.799575] dfe0: 76400cc8 7e915fd8 75f73957 76f0235a 60000030 00000009 00000000 00000000
    [133329.805040]  vchiq_mmal_port_enable [bcm2835_mmal_vchiq] from bcm2835_codec_start_streaming+0x1f4/0x3bc [bcm2835_codec]
    [133329.810637]  bcm2835_codec_start_streaming [bcm2835_codec] from vb2_start_streaming+0x64/0x170 [videobuf2_common]
    [133329.816249]  vb2_start_streaming [videobuf2_common] from vb2_core_streamon+0x88/0x178 [videobuf2_common]
    [133329.821863]  vb2_core_streamon [videobuf2_common] from v4l2_m2m_streamon+0x28/0x58 [v4l2_mem2mem]
    [133329.827456]  v4l2_m2m_streamon [v4l2_mem2mem] from __video_do_ioctl+0x228/0x454 [videodev]
    [133329.833215]  __video_do_ioctl [videodev] from video_usercopy+0x138/0x5dc [videodev]
    [133329.839122]  video_usercopy [videodev] from sys_ioctl+0x120/0x984
    [133329.842123]  sys_ioctl from __sys_trace_return+0x0/0x10
    [133329.844836] Exception stack(0xbc24dfa8 to 0xbc24dff0)
    [133329.847483] dfa0:                   40045612 734ef900 00000009 40045612 7e916108 7e916108
    [133329.852647] dfc0: 40045612 734ef900 734ef900 00000036 00000009 734b2880 734ef800 00000000
    [133329.857783] dfe0: 76400cc8 7e915fd8 75f73957 76f0235a
    [133329.860349] Code: e250a000 1affffdc e8940006 e3a00c01 (e5812004)
    

    Any following attempts to use the encoder result with the following log messages:

    [137232.618666] bcm2835-codec bcm2835-codec: Mutex fail
    [143268.420861] bcm2835-codec bcm2835-codec: Mutex fail
    [161930.260120] bcm2835-codec bcm2835-codec: Mutex fail
    [161960.690046] bcm2835-codec bcm2835-codec: Mutex fail
    [162039.325677] bcm2835-codec bcm2835-codec: Mutex fail
    

    I'm guessing some null pointer is being dereferenced after the lock is acquired and then it's never released blocking future attempts.

  7. stsichler commented on Aug 4, 2025

    @stsichler

    I think I am also affected by this bug on my RasPi3B+ on up-to-date Raspberry Pi OS Lite (Debian Bookworm based), running kernel 6.12.41-v8+ (installed by rpi-update). I also tested previous 6.12 kernels, all showing this bug.

    What I'm trying to do is transcoding video data to h264 from an USB webcam using
    ffmpeg -f v4l2 -framerate 10 -video_size 1280x720 -i /dev/video0 -pix_fmt yuv420p -c:v h264_v4l2m2m -b:v 1000k (...)

    This almost always results in an immediate crash (see log below).
    But I made an interesting observation:
    Transcoding works without crash when I previously "re-plug" the USB Camera by calls to
    uhubctl -l 1-1 -p 2-5 -a off and uhubctl -l 1-1 -p 2-5 -a on

    Crash Log:

    [ 116.139660] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
    [ 116.139780] Mem abort info:
    [ 116.139813] ESR = 0x0000000096000045
    [ 116.139850] EC = 0x25: DABT (current EL), IL = 32 bits
    [ 116.139900] SET = 0, FnV = 0
    [ 116.140004] EA = 0, S1PTW = 0
    [ 116.140039] FSC = 0x05: level 1 translation fault
    [ 116.140086] Data abort info:
    [ 116.140116] ISV = 0, ISS = 0x00000045, ISS2 = 0x00000000
    [ 116.140176] CM = 0, WnR = 1, TnD = 0, TagAccess = 0
    [ 116.140224] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
    [ 116.140275] user pgtable: 4k pages, 39-bit VAs, pgdp=000000000aada000
    [ 116.140344] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000
    [ 116.140432] Internal error: Oops: 0000000096000045 [#1] PREEMPT SMP
    [ 116.140490] Modules linked in: cmac algif_hash aes_arm64 aes_generic algif_skcipher af_alg bnep zram lz4_compress brcmfmac_wcc brcmfmac binfmt_misc brcmutil hci_uart cfg80211 bcm2835_isp(C) btbcm bcm2835_codec(C) bcm2835_v4l2(C) bluetooth uvcvideo bcm2835_mmal_vchiq(C) vc_sm_cma(C) v4l2_mem2mem videobuf2_vmalloc videobuf2_dma_contig uvc videobuf2_memops videobuf2_v4l2 ecdh_generic videodev raspberrypi_hwmon ecc rfkill snd_bcm2835(C) videobuf2_common libaes mc snd_pcm snd_timer i2c_bcm2835 snd raspberrypi_gpiomem uio_pdrv_genirq uio i2c_dev drm fuse dm_mod drm_panel_orientation_quirks backlight ip_tables x_tables ipv6
    [ 116.144655] CPU: 1 UID: 0 PID: 592 Comm: ffmpeg Tainted: G C 6.12.41-v8+ #1897
    [ 116.146621] Tainted: [C]=CRAP
    [ 116.147568] Hardware name: Raspberry Pi 3 Model B Rev 1.2 (DT)
    [ 116.148536] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    [ 116.149534] pc : vchiq_mmal_port_enable+0xd4/0x160 [bcm2835_mmal_vchiq]
    [ 116.150558] lr : vchiq_mmal_port_enable+0x114/0x160 [bcm2835_mmal_vchiq]
    [ 116.151572] sp : ffffffc081293a60
    [ 116.152585] x29: ffffffc081293a60 x28: 0000000000000002 x27: dead000000000100
    [ 116.153645] x26: dead000000000122 x25: ffffff8008d80218 x24: 0000000000000000
    [ 116.154708] x23: ffffff8008d80008 x22: ffffff8008d80000 x21: ffffff8009a7ca38
    [ 116.155772] x20: ffffff8008d80170 x19: 0000000000000000 x18: ffffffffffffffff
    [ 116.156830] x17: 0000000181293b58 x16: ffffffe082b051c0 x15: ffffffc0812937f8
    [ 116.157894] x14: 0000000000000003 x13: ffffffc0812937d8 x12: bcbcbcbcbcbcbcbc
    [ 116.158952] x11: bcbcbcbcbcbcbcbc x10: 000000000000003a x9 : ffffffe082b051fc
    [ 116.160007] x8 : 000000000000003a x7 : 000000000000001f x6 : 0000000000000030
    [ 116.161044] x5 : ffffff8004f5001c x4 : 0000000000000000 x3 : 0000000000000001
    [ 116.162064] x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000000
    [ 116.163059] Call trace:
    [ 116.164004] vchiq_mmal_port_enable+0xd4/0x160 [bcm2835_mmal_vchiq]
    [ 116.164971] bcm2835_codec_start_streaming+0x17c/0x488 [bcm2835_codec]
    [ 116.165923] vb2_start_streaming+0x74/0x190 [videobuf2_common]
    [ 116.166877] vb2_core_streamon+0x128/0x1f0 [videobuf2_common]
    [ 116.167808] vb2_streamon+0x24/0x80 [videobuf2_v4l2]
    [ 116.168714] v4l2_m2m_ioctl_streamon+0x40/0xa8 [v4l2_mem2mem]
    [ 116.169625] v4l_streamon+0x2c/0x40 [videodev]
    [ 116.170577] __video_do_ioctl+0x194/0x400 [videodev]
    [ 116.171483] video_usercopy+0x31c/0x758 [videodev]
    [ 116.172391] video_ioctl2+0x20/0x38 [videodev]
    [ 116.173291] v4l2_ioctl+0x48/0x70 [videodev]
    [ 116.174170] __arm64_sys_ioctl+0xb0/0x100
    [ 116.174976] invoke_syscall+0x50/0x120
    [ 116.175780] el0_svc_common.constprop.0+0x48/0xf8
    [ 116.176568] do_el0_svc+0x28/0x40
    [ 116.177346] el0_svc+0x30/0x100
    [ 116.178104] el0t_64_sync_handler+0x13c/0x158
    [ 116.178866] el0t_64_sync+0x190/0x198
    [ 116.179619] Code: f2fbd5bb f2fbd5ba 1400000d a94002a1 (f9000420)
    [ 116.180387] ---[ end trace 0000000000000000 ]---

  8. stsichler commented on Aug 5, 2025

    @stsichler

    Hm, ok. The crash seems not to be 100% reproducable and thus feels like a race condition.
    I checked all component / port initialization code, esp. vchiq_mmal_component_init(), building up port data, and vchiq_mmal_port_enable() and it seems that instance->vchiq_mutex is always held correctly for synchronization.
    The only thing that is suspicious to me is that lookup_msg_context() does not lock instance->context_map_lock , but that seems unrelated.

  9. jclaveau commented on Nov 2, 2026

    @jclaveau

    Edit (2026-11-02): root cause found in bcm2835-v4l2-codec.c; the locking patch I first posted here was wrong and is replaced below.

    I have a deterministic reproducer for this oops: any h264_v4l2m2m encode that reaches EOF before the first frame is sent.

    Steps to reproduce

    Raspberry Pi OS, stock ffmpeg (5.1.9-0+deb12u1+rpt1):

    ffmpeg -f lavfi -i testsrc=size=1280x720:rate=24 -t 0 -c:v h264_v4l2m2m -b:v 2M -f null -
    

    Results:

    command in-tree module result
    -t 0 (zero frames), Pi OS ffmpeg 5.1.9 stock oops 2/2
    -t 0 (zero frames), jellyfin-ffmpeg 7.1.4 stock oops 1/1
    -frames:v 1 (one frame), both ffmpeg builds stock no oops

    Every oops is the same as in this issue: vchiq_mmal_port_enable+0xd4 ← bcm2835_codec_start_streaming, write to 0x8, then bcm2835-codec: Mutex fail on every later use until a reboot.

    Why Jellyfin hits it, which is probably also why several people here see it on seek or on the next episode: my files have audio ~14 s longer than the video stream. When the player moves to the next episode, Jellyfin requests the last HLS segment (-ss past the last video frame), so the filtergraph yields zero frames (No filtered frames for output stream, trying to initialize anyway) and the encoder is started and drained without input. Its exact command line oopsed the stock module 4/4 when replayed, and subtitles, HLS output and -copyts don't matter (bisected).

    System

    $ cat /etc/rpi-issue
    Raspberry Pi reference 2025-05-13
    Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 5dabc7dc940059dfbc46af5d97b60a1e812523dd, stage2
    
    $ vcgencmd version
    May 21 2026 11:20:25
    Copyright (c) 2012 Broadcom
    version 288930ab4712b99596f32732664aaaeb881ef1e0 (clean) (release) (start)
    
    $ uname -a
    Linux naspi 6.12.93+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.93-1+rpt1 (2026-06-12) aarch64 GNU/Linux
    

    Raspberry Pi 4 Model B Rev 1.4. The system also runs OpenMediaVault on top of Pi OS. I haven't tested a 6.18 kernel, but the EOS handling below is unchanged in rpi-6.18.y.

    Logs

    From an untainted stock boot (the Jellyfin command replayed by hand):

    oops
    Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
    Mem abort info:
      ESR = 0x0000000096000045
      EC = 0x25: DABT (current EL), IL = 32 bits
      SET = 0, FnV = 0
      EA = 0, S1PTW = 0
      FSC = 0x05: level 1 translation fault
    Data abort info:
      ISV = 0, ISS = 0x00000045, ISS2 = 0x00000000
      CM = 0, WnR = 1, TnD = 0, TagAccess = 0
      GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
    user pgtable: 4k pages, 39-bit VAs, pgdp=00000000bef22000
    [0000000000000008] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000
    Internal error: Oops: 0000000096000045 [#1] PREEMPT SMP
    Modules linked in: nf_conntrack_netlink xt_nat veth bridge stp llc xfrm_user xfrm_algo xt_set ip_set xt_addrtype quota_v2 quota_tree xt_connmark xt_conntrack xt_MASQUERADE xt_tcpudp xt_mark nft_compat nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 tun nf_tables nfnetlink cmac algif_hash aes_arm64 aes_generic overlay algif_skcipher af_alg bnep binfmt_misc brcmfmac_wcc hci_uart btbcm bluetooth vc4 v3d ecdh_generic bcm2835_isp(C) ecc bcm2835_v4l2(C) bcm2835_codec(C) snd_soc_hdmi_codec gpu_sched brcmfmac drm_display_helper libaes cec sg drm_shmem_helper drm_dma_helper bcm2835_mmal_vchiq(C) brcmutil vc_sm_cma(C) rpi_hevc_dec drm_kms_helper raspberrypi_hwmon v4l2_mem2mem videobuf2_vmalloc videobuf2_dma_contig snd_soc_core snd_bcm2835(C) snd_compress snd_pcm_dmaengine videobuf2_memops snd_pcm i2c_brcmstb videobuf2_v4l2 snd_timer videodev raspberrypi_gpiomem videobuf2_common mc snd nvmem_rmem cfg80211 rfkill drm fuse dm_mod drm_panel_orientation_quirks backlight ip_tables x_tables ipv6 efivarfs
     raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor xor xor_neon async_tx raid6_pq raid1 raid0 md_mod uio_pdrv_genirq uio
    CPU: 1 UID: 0 PID: 5949 Comm: ffmpeg Tainted: G         C         6.12.93+rpt-rpi-v8 #1  Debian 1:6.12.93-1+rpt1
    Tainted: [C]=CRAP
    Hardware name: Raspberry Pi 4 Model B Rev 1.4 (DT)
    pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    pc : vchiq_mmal_port_enable+0xd4/0x160 [bcm2835_mmal_vchiq]
    lr : vchiq_mmal_port_enable+0x114/0x160 [bcm2835_mmal_vchiq]
    sp : ffffffc085b9ba90
    x29: ffffffc085b9ba90 x28: 0000000000000002 x27: dead000000000100
    x26: dead000000000122 x25: ffffff80825c0218 x24: 0000000000000000
    x23: ffffff80825c0008 x22: ffffff80825c0000 x21: ffffff80404c6a38
    x20: ffffff80825c0170 x19: 0000000000000000 x18: 0000000000000003
    x17: 0000000100000000 x16: ffffffde40725378 x15: ffffffc085b9b630
    x14: ffffffc085b9b7f8 x13: ffffffc085b9b7d8 x12: bcbcbcbcbcbcbcbc
    x11: bcbcbcbcbcbcbcbc x10: 000000000000003a x9 : ffffffde407253b4
    x8 : 000000000000003a x7 : 0000000000000003 x6 : 000000000000003a
    x5 : ffffff804490981c x4 : 0000000000000000 x3 : 0000000000000001
    x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000000
    Call trace:
     vchiq_mmal_port_enable+0xd4/0x160 [bcm2835_mmal_vchiq]
     bcm2835_codec_start_streaming+0x17c/0x488 [bcm2835_codec]
     vb2_start_streaming+0x74/0x190 [videobuf2_common]
     vb2_core_streamon+0x108/0x1d8 [videobuf2_common]
     vb2_streamon+0x20/0x78 [videobuf2_v4l2]
     v4l2_m2m_ioctl_streamon+0x40/0xa8 [v4l2_mem2mem]
     v4l_streamon+0x2c/0x40 [videodev]
     __video_do_ioctl+0x184/0x400 [videodev]
     video_usercopy+0x1c0/0x790 [videodev]
     video_ioctl2+0x20/0x38 [videodev]
     v4l2_ioctl+0x48/0x70 [videodev]
     __arm64_sys_ioctl+0xbc/0x100
     invoke_syscall+0x4c/0xf8
     el0_svc_common.constprop.0+0xc8/0xf0
     do_el0_svc+0x24/0x38
     el0_svc+0x30/0x100
     el0t_64_sync_handler+0xc8/0xe0
     el0t_64_sync+0x190/0x198
    Code: f2fbd5bb f2fbd5ba 1400000d a94002a1 (f9000420) 
    ---[ end trace 0000000000000000 ]---
    

    Registers x26/x27 hold LIST_POISON2/LIST_POISON1. The faulting store f9000420 (str x0, [x1, #8]) has x1 = 0, so list_del() in the port->buffers loop of port_enable() meets an entry whose next and prev are NULL.

    Root cause

    When ffmpeg reaches EOF before its first frame, it issues VIDIOC_ENCODER_CMD(V4L2_ENC_CMD_STOP) before VIDIOC_STREAMON on the OUTPUT queue. Then:

    1. vidioc_encoder_cmd() submits q_data->eos_buffer to component->input[0]. That port is still disabled, so vchiq_mmal_submit_buffer() queues the buffer on port->buffers.
    2. VIDIOC_STREAMON(OUTPUT) → bcm2835_codec_start_streaming() does memset(&q_data->eos_buffer, 0, sizeof(q_data->eos_buffer)) while the buffer is still linked on that list, so its list.next/list.prev become NULL.
    3. vchiq_mmal_port_enable() → port_enable() walks port->buffers and list_del()s that entry: __list_del(NULL, NULL) writes to 0x8.

    dev-encoder.rst says a STOP issued while a queue isn't streaming must not fail but must not start a drain either. vidioc_decoder_cmd() has the same path.

    Fix

    Hold the EOS back while the MMAL input port is disabled, and send it right after start_streaming() enables the port. The memset no longer touches a queued buffer, and a client that asked for a drain before its first frame still gets its EOS.

    Tested on the system above (DKMS build of bcm2835-codec from rpi-6.12.y; an unpatched build of the same file gives the stock module's srcversion), with the stock bcm2835-mmal-vchiq, so the codec patch is the only change:

    test stock codec patched codec
    zero-frame encode, Pi OS ffmpeg 5.1.9 and jellyfin-ffmpeg 7.1.4 oops, same +0xd4 pc no oops in 12 runs (6 each); both exit 0 within 3–5 s
    Jellyfin's last-segment command, replayed after a reboot oops (4/4 earlier) no oops 3/3; ffmpeg exits on its own and writes #EXT-X-ENDLIST
    1-frame and 48-frame encodes, both builds — normal H.264 output, no errors in dmesg
    patch (drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c)
    --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
    +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
    @@ -672,6 +672,8 @@
     	/* One extra buffer header so we can send an EOS. */
     	struct m2m_mmal_buffer	eos_buffer;
     	bool			eos_buffer_in_use;	/* debug only */
    +	/* STOP received while the MMAL input port was disabled */
    +	bool			eos_buffer_pending;
     };
     
     struct bcm2835_codec_dev {
    @@ -2474,6 +2476,32 @@
     	return 0;
     }
     
    +/*
    + * A STOP can arrive before VIDIOC_STREAMON(OUTPUT), e.g. when the client hits
    + * end of stream before its first frame. Submitted then, the EOS buffer would
    + * be queued on the disabled port's buffer list, and start_streaming() would
    + * memset it while still linked: port_enable() then oopses in list_del() on
    + * its NULL pointers. Hold the EOS back until the port is enabled.
    + */
    +static int bcm2835_codec_submit_eos(struct bcm2835_codec_ctx *ctx,
    +				    struct bcm2835_codec_q_data *q_data)
    +{
    +	if (!ctx->component->input[0].enabled) {
    +		q_data->eos_buffer_pending = true;
    +		return 0;
    +	}
    +
    +	q_data->eos_buffer.mmal.buffer_size = 0;
    +	q_data->eos_buffer.mmal.length = 0;
    +	q_data->eos_buffer.mmal.mmal_flags = MMAL_BUFFER_HEADER_FLAG_EOS;
    +	q_data->eos_buffer.mmal.pts = 0;
    +	q_data->eos_buffer.mmal.dts = 0;
    +
    +	return vchiq_mmal_submit_buffer(ctx->dev->instance,
    +					&ctx->component->input[0],
    +					&q_data->eos_buffer.mmal);
    +}
    +
     static int vidioc_decoder_cmd(struct file *file, void *priv,
     			      struct v4l2_decoder_cmd *cmd)
     {
    @@ -2494,19 +2522,10 @@
     			v4l2_err(&ctx->dev->v4l2_dev, "EOS buffers already in use\n");
     		q_data->eos_buffer_in_use = true;
     
    -		q_data->eos_buffer.mmal.buffer_size = 0;
    -		q_data->eos_buffer.mmal.length = 0;
    -		q_data->eos_buffer.mmal.mmal_flags =
    -						MMAL_BUFFER_HEADER_FLAG_EOS;
    -		q_data->eos_buffer.mmal.pts = 0;
    -		q_data->eos_buffer.mmal.dts = 0;
    -
     		if (!ctx->component)
     			break;
     
    -		ret = vchiq_mmal_submit_buffer(ctx->dev->instance,
    -					       &ctx->component->input[0],
    -					       &q_data->eos_buffer.mmal);
    +		ret = bcm2835_codec_submit_eos(ctx, q_data);
     		if (ret)
     			v4l2_err(&ctx->dev->v4l2_dev,
     				 "%s: EOS buffer submit failed %d\n",
    @@ -2562,19 +2581,10 @@
     			v4l2_err(&ctx->dev->v4l2_dev, "EOS buffers already in use\n");
     		q_data->eos_buffer_in_use = true;
     
    -		q_data->eos_buffer.mmal.buffer_size = 0;
    -		q_data->eos_buffer.mmal.length = 0;
    -		q_data->eos_buffer.mmal.mmal_flags =
    -						MMAL_BUFFER_HEADER_FLAG_EOS;
    -		q_data->eos_buffer.mmal.pts = 0;
    -		q_data->eos_buffer.mmal.dts = 0;
    -
     		if (!ctx->component)
     			break;
     
    -		ret = vchiq_mmal_submit_buffer(ctx->dev->instance,
    -					       &ctx->component->input[0],
    -					       &q_data->eos_buffer.mmal);
    +		ret = bcm2835_codec_submit_eos(ctx, q_data);
     		if (ret)
     			v4l2_err(&ctx->dev->v4l2_dev,
     				 "%s: EOS buffer submit failed %d\n",
    @@ -3126,10 +3136,13 @@
     		 * We only need the MMAL part, and want to NOT attach a memory
     		 * buffer to it as it should only take flags.
     		 */
    +		bool eos_pending = q_data->eos_buffer_pending;
    +
     		memset(&q_data->eos_buffer, 0, sizeof(q_data->eos_buffer));
     		mmal_vchi_buffer_init(dev->instance,
     				      &q_data->eos_buffer.mmal);
    -		q_data->eos_buffer_in_use = false;
    +		q_data->eos_buffer_in_use = eos_pending;
    +		q_data->eos_buffer_pending = false;
     
     		ret = vchiq_mmal_port_enable(dev->instance,
     					     port,
    @@ -3137,6 +3150,9 @@
     		if (ret)
     			v4l2_err(&ctx->dev->v4l2_dev, "%s: Failed enabling i/p port, ret %d\n",
     				 __func__, ret);
    +		else if (eos_pending)
    +			/* Drain asked before any frame: send the EOS now. */
    +			ret = bcm2835_codec_submit_eos(ctx, q_data);
     	} else {
     		if (!port->enabled) {
     			ret = vchiq_mmal_port_enable(dev->instance,

    Assisted-by: Claude:claude-opus-5-5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions