bcm2835-codec: NULL deref Oops after STREAMOFF / buffer-return race (Pi 4, Chromium H.264 decode, 6.18.50 and 6.18.60)

Abierto
#7,787 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
8/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
c, linux, raspberry-pi

Línea de trabajo

The race sits in the bcm2835-codec driver: start with buffer_work_cb and the stop_streaming path in drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c, and the videobuf2 cancel path in videobuf2-core.c near lines 1187 and 2222. Done would mean the NULL dereferences from the stop path no longer occur under a reproducer that stops the decoder while firmware returns buffers, but no reproducer exists yet. This is kernel-internal concurrency work and is not suited to a first contribution.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug

(with help of Claude ;-) ) i hope this helps others and you for fixing... Rob

On a Pi 4 running a Chromium kiosk, stopping the V4L2 hardware decoder occasionally triggers a WARNING in videobuf2. In 5 cases it coincided with a second WARNING in vb2_buffer_done on another CPU, and in 4 of those a NULL-pointer Oops followed within 12-300 ms in the bcm2835-codec / videobuf2-dma-contig path. After the Oops of 2026-11-23 the Chromium GPU process hung in D state inside a CMA allocation about 55 minutes later, which froze the display and touch (the machine stayed reachable over ssh). It happens on 6.18.50 and on 6.18.60.

I looked at the similar issues GitHub suggested (#7712, #7163, #7721). #7712 and #7163 are related in part, see "Additional context".

Steps to reproduce the behaviour

Not reproducible on demand; it happens sporadically on a kiosk that runs 24/7.

  1. Pi 4, Raspberry Pi OS (trixie, arm64), X11 session with openbox, Chromium in --app (kiosk) mode.
  2. The kiosk page rotates between a few dashboards every 20-30 s; one full rotation takes 80 s (the camera page is requested every 80 s according to my web server log).
  3. One dashboard plays three low-latency HLS streams from MediaMTX (all H.264, 640x360, 15-20 fps, about 0.2 Mbit/s each, video only: avc1.4d0016 for one, avc1.640016 for two). While that page is shown the Chromium GPU process has a /dev/video* node open; on the other dashboards it does not (checked via /proc//fd on 2026-11-11). So the decoder is started and stopped about every 80 s, roughly 1,000 times a day. The firmware log in the attached raspinfo shows one or two "video_decode:NN:RIL: resolution changing" messages per rotation.
  4. Leave it running. The events also happen at night when nobody is looking (e.g. 2026-11-09 05:51).
Device (s)

Raspberry Pi 4 Mod. B

System
  • Raspberry Pi reference 2026-06-18 (pi-gen ca8aeed0ae300c2a89f55ce9617d5f96a27e99e5, stage4), Debian 13 trixie, arm64; Xorg with KMS (vc4-kms-v3d-pi4), openbox
  • Kernel 6.18.50+rpt-rpi-v8 (1:6.18.50-1+rpt1) until 2026-11-08, 6.18.60+rpt-rpi-v8 (1:6.18.60-1+rpt1) from 2026-11-08 to 2026-11-12, and 6.18.50 again since 2026-11-12 13:06 (rolled back by copying vmlinuz/initrd into /boot/firmware; kernel packages on hold). Tainted G C (staging drivers), W after the first WARNING of a boot.
  • Firmware Sep 14 2026 14:49:30 (a86983925695a7e63166327d7c002d64040ed31d), bootloader EEPROM 2026-10-30, up to date
  • Chromium 155.0.8059.79 until 2026-11-08, 156.0.8078.79 since. Mesa 26.2.2 until 2026-11-08, then 26.2.6; 26.2.7 and rpi-chromium-mods 20261111 since 2026-11-22.
  • Relevant Chromium flags: --use-angle=gles --enable-gpu-rasterization --ozone-platform=x11; hardware video decode left at the default (enabled)
  • vcgencmd get_throttled = 0x0. See the attached raspinfo.
Logs

Combined event = WARNING at videobuf2-core.c:1187 (vb2_buffer_done, from buffer_work_cb) and WARNING at :2222 (__vb2_queue_cancel via v4l2_m2m_streamoff from Chromium's ThreadPoolSingl) in the same second, on different CPUs:

  • 2026-11-11 12:15:57 (6.18.60): via ip_buffer_cb, no Oops
  • 2026-11-11 19:04:40 (6.18.60): via ip_buffer_cb, Oops 16 ms later
  • 2026-11-12 11:40:58 (6.18.60): via ip_buffer_cb, Oops 19 ms later
  • 2026-11-13 15:42:48 (6.18.50): via op_buffer_cb, Oops about 300 ms later (15:42:49); "driver bug: stop_streaming operation is leaving buffer 6/7/8 in active state" in the same second
  • 2026-11-23 09:29:32 (6.18.50): via ip_buffer_cb, Oops 12 ms later; "driver bug: ... buffer 0/1/2/13/14/15 in active state" in the same second

The four Oopses (full traces in the attachment):

  1. 2026-11-11 19:04:40, 6.18.60, kworker (delayed_fput): NULL deref at 0x248, dma_release_from_dev_coherent <- dma_free_attrs <- vb2_dc_put <- vb2_dc_dmabuf_ops_release <- dma_buf_release <- __dentry_kill <- dput <- __fput <- delayed_fput
  2. 2026-11-12 11:40:58, 6.18.60, Chromium ThreadPoolSingl: NULL deref at 0x40, mutex_lock <- mmal_vchi_buffer_cleanup <- bcm2835_codec_buffer_cleanup <- __vb2_queue_free <- vb2_core_reqbufs <- vb2_reqbufs <- v4l2_m2m_ioctl_reqbufs <- v4l_reqbufs
  3. 2026-11-13 15:42:49, 6.18.50, Chromium (close() syscall): same signature as 1 (0x248, vb2_dc_put <- vb2_dc_dmabuf_ops_release <- dma_buf_release), via fput_close_sync / __arm64_sys_close instead of delayed_fput
  4. 2026-11-23 09:29:32, 6.18.50, kworker (delayed_fput): same signature as 1 (0x248)

My reading is that the firmware returns buffers (buffer_work_cb) while the decoder is being stopped, and the driver then touches state that is already gone. That is an interpretation of the traces, not something I verified in the source.

Consequence of the 2026-11-23 Oops: the last request from the kiosk page was at 10:24:40, about 55 minutes after the Oops. The Chromium GPU process was stuck in D state, could not be killed, load average 1.0 on an otherwise idle CPU:

__flush_work+0x258/0x350
flush_work+0x1c/0x30
__lru_add_drain_all+0x164/0x208
lru_cache_disable+0x68/0x80
alloc_contig_range_noprof+0x210/0x940
__cma_alloc+0x1b4/0x6e0
cma_alloc+0x28/0x40
cma_alloc_aligned+0x4c/0x60
dma_alloc_contiguous+0x38/0x60
dma_direct_alloc+0x118/0x3d0
dma_alloc_attrs+0x94/0x238
drm_gem_dma_create+0xb4/0x160 [drm_dma_helper]
drm_gem_dma_dumb_create_internal+0x60/0x80 [drm_dma_helper]
vc5_dumb_create+0x54/0x68 [vc4]
drm_mode_create_dumb_ioctl+0x98/0xc0 [drm]

After the Oops of 2026-11-11 the display and touch also froze (I did not capture a stack that time). After the Oopses of 11-12 and 11-13 I did not check whether the display froze.

Attached: kernelerror-syslogs.txt (all four Oopses with context), kernelissue-raspinfo-clean.txt (serial number, MAC address and EDID removed).

kernelissue-raspinfo-clean.txt

kernelerror-syslogs.txt

Additional context
  • Frequency: not deterministic. WARNING :2222 without the second warning: 2026-10-14, 10-15, 10-27 (six times between 11:31 and 21:47), 11-09 (05:51, 22:58), 11-11 14:58, 11-16, 11-20 (08:03, 14:37). No videobuf2 WARNING at all between 10-27 and 11-09. My logs start on 2026-10-11.
  • The :1187 combination and the Oopses do not appear in my logs before 2026-11-11 (10-11 to 11-10). On 2026-11-08 I updated several things at once (kernel 6.18.50 -> 6.18.60, Chromium 155 -> 156, Mesa 26.2.2 -> 26.2.6). Rolling back the kernel to 6.18.50 did not stop the Oopses (11-13, 11-23), so it is not specific to 6.18.60; I cannot tell whether Chromium 156 or Mesa matter.
  • Same messages as in #7712: "bcm2835_codec_flush_buffers: Timeout waiting for buffers to be returned - 0 outstanding", 8 times between 2026-10-26 and 2026-11-15 (10-26, 10-30, 11-01, 11-06, 11-12, 11-13 twice, 11-15), on both kernels. I have not tested the patch in #7713. It could be the same race with a more severe outcome here, but I cannot show that.
  • #7163 (CM4, MMAL timeouts and videobuf2 warnings when stopping live H.264): I see the same "driver bug ... leaving buffer in active state" lines (on 11-13 and 11-23) and a later comment there reports an Oops. I do not see "timed out waiting for sync completion" messages in my kernel log, so no firmware wedge as described there.
  • Also seen: "bcm2835_mmal_vchiq: buffer_work_cb: ... No mmal buffer to pass details" (2026-11-11 15:15 and 15:45) and "vc_sm_cma_vchi_rx_ack: received response 0, throw away..." on most days, also directly before the 11-11 events.
  • Not tested: --disable-accelerated-video-decode, other kernel versions, a reproducer without Chromium, the patch in #7713.
  • Related: Ubuntu LP #1915411 (similar __vb2_queue_cancel WARNING when stopping bcm2835-codec streams).
Lenguaje dominante
C
Estrellas
13.4k
Forks
5.5k
Merge medio
2 d 11 h
PR fusionados (30 d)
32

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de raspberrypi/linux

Todos los issues de raspberrypi/linux

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.