Repository navigation
Open
Description
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
Reacted by tangxinfa, Domingo Ramirez, elgorro, Roger D, Szymon Marczak and Freddy McGroarty
Metadata
Metadata
Assignees
Labels
No labels
Activity
chuma9615 commentedon Aug 9, 2022
Any update on this? We've been having this exact same crash consistently while hardware encoding a live RSTP input
chuma9615 commentedon Aug 9, 2022
Describe the bug
Sometimes when encoding a livestream using
ffmpegthe 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 systemSteps to reproduce the behaviour
Hardware encode a RSTP stream using
h264_v4l2m2mencoderCommand
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.tsDevice (s)
Raspberry Pi CM4 4GB RAM
System
Logs
roger- commentedon Nov 16, 2022
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:
TubaApollo commentedon Nov 19, 2022
Same issue here, seems to be especially an issue when seeking fast for me
(Raspberry Pi 4 Model B Rev 1.4 (DT))
huelsenfruchtzwerg commentedon Dec 1, 2022
Same issue here
shmuelzon commentedon Apr 21, 2023
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/LinuxUsing the encoder from time to time for a few minutes and at some point it just stops working with the following crash dump:
Any following attempts to use the encoder result with the following log messages:
I'm guessing some null pointer is being dereferenced after the lock is acquired and then it's never released blocking future attempts.
stsichler commentedon Aug 4, 2025
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 offanduhubctl -l 1-1 -p 2-5 -a onCrash 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 ]---
stsichler commentedon Aug 5, 2025
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_mutexis 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.jclaveau commentedon Nov 2, 2026
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_v4l2m2mencode that reaches EOF before the first frame is sent.Steps to reproduce
Raspberry Pi OS, stock ffmpeg (
5.1.9-0+deb12u1+rpt1):Results:
-t 0(zero frames), Pi OS ffmpeg 5.1.9-t 0(zero frames), jellyfin-ffmpeg 7.1.4-frames:v 1(one frame), both ffmpeg buildsEvery oops is the same as in this issue:
vchiq_mmal_port_enable+0xd4←bcm2835_codec_start_streaming, write to0x8, thenbcm2835-codec: Mutex failon 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 (
-sspast 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-copytsdon't matter (bisected).System
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
Registers
x26/x27holdLIST_POISON2/LIST_POISON1. The faulting storef9000420(str x0, [x1, #8]) hasx1 = 0, solist_del()in theport->buffersloop ofport_enable()meets an entry whosenextandprevare NULL.Root cause
When ffmpeg reaches EOF before its first frame, it issues
VIDIOC_ENCODER_CMD(V4L2_ENC_CMD_STOP)beforeVIDIOC_STREAMONon the OUTPUT queue. Then:vidioc_encoder_cmd()submitsq_data->eos_buffertocomponent->input[0]. That port is still disabled, sovchiq_mmal_submit_buffer()queues the buffer onport->buffers.VIDIOC_STREAMON(OUTPUT)→bcm2835_codec_start_streaming()doesmemset(&q_data->eos_buffer, 0, sizeof(q_data->eos_buffer))while the buffer is still linked on that list, so itslist.next/list.prevbecome NULL.vchiq_mmal_port_enable()→port_enable()walksport->buffersandlist_del()s that entry:__list_del(NULL, NULL)writes to0x8.dev-encoder.rstsays 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-codecfrom rpi-6.12.y; an unpatched build of the same file gives the stock module's srcversion), with the stockbcm2835-mmal-vchiq, so the codec patch is the only change:+0xd4pc#EXT-X-ENDLISTpatch (drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c)
Assisted-by: Claude:claude-opus-5-5
staging: bcm2835-codec: Defer EOS until the input port is enabled