1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-28 15:19:38 +03:00
Files
ffmpeg/libavcodec
Diego de Souza e0a878dd70 avcodec/dxva2: fix frame->buf[] data race with frame threading
ff_dxva2_common_end_frame() adds a reference to the decoder to
frame->buf[], so that the decoder outlives the frames decoded with it.
It is called from the hwaccel end_frame() callback, which with frame
threading may run after ff_thread_finish_setup(). From that point on,
other threads may copy the frame: the H.264 decoder keeps a separate
AVFrame per picture in each thread and synchronizes them in
update_thread_context() with av_frame_replace(), which reads
frame->buf[] while the decoding thread may be writing to it. As noted
in fa77cb258b ("avcodec/h264dec: Fix data race when updating
decode_error_flags"), a decoding thread must not modify any field that
av_frame_ref() copies after ff_thread_finish_setup().

This has been observed as an intermittent access violation in
av_buffer_replace() when decoding H.264 with D3D11VA and frame
threading on Windows on Arm: the copying thread read a non-NULL
frame->buf[1] entry, but saw the fields of the AVBufferRef it points
to as zero, and dereferenced the NULL buffer pointer when incrementing
the reference count.

Store the decoder reference in FrameDecodeData.hwaccel_priv instead,
as nvdec does for its per-frame state. The decode data is attached to
frame->private_ref when the buffer is allocated, before
ff_thread_finish_setup(), and all references to the frame share it, so
update_thread_context() only takes a new reference to it. The decoder
reference is added to frame->buf[] by hwaccel_priv_post_process(),
which runs in the caller's thread when the frame is returned, so
returned frames keep the decoder alive. Since the decode data
is shared, the second field of a field pair no longer adds a second
decoder reference to the frame.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
(cherry picked from commit 538d10d187)
2026-10-08 21:34:32 +02:00
..
…
…
…
…
…
…
…
…
2025-11-05 16:31:59 +00:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-10-08 20:40:08 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-12-13 18:45:17 -03:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2026-05-03 19:25:01 +02:00
…
…
…
2025-11-26 15:16:42 +01:00
…
…
…
…
…
…
…
…
…
…
2025-11-08 18:48:54 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2026-03-10 19:32:38 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-10-30 03:41:24 +01:00
…
…
…
…
…
…
…
…
…
…
2026-01-02 18:39:48 +01:00
2026-01-02 18:39:48 +01:00
2026-01-02 18:39:48 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-11-26 15:16:43 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-12-13 18:45:17 -03:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2026-09-19 14:26:52 +02:00
2026-09-19 14:26:52 +02:00
…
…
…
…
…
…
…
2026-06-14 04:41:07 +02:00
2025-12-30 17:30:45 +00:00
…
…
…
…
…
…
…
…
…
…
…
…
2026-01-02 18:39:48 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2026-05-03 19:24:55 +02:00
…
…
…
…
…
…
…
…
…
…
…
2026-03-07 19:22:40 -03:00
…
…
…
…
…
…
…
…
2026-01-10 22:47:22 +01:00
2026-02-04 12:05:35 +08:00
2026-02-04 12:05:35 +08:00
…
…
…
2026-02-11 20:35:20 +00:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2026-02-19 22:39:35 +00:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2026-03-02 19:01:46 +01:00
2026-03-02 19:01:46 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2026-09-19 18:28:12 +02:00
…
…
…
…
…
…
2026-03-03 02:41:05 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-12-30 14:39:08 -05:00
2025-12-30 14:39:08 -05:00
…
…
…
…
…
…
…
…
…
…
…
…
2026-02-23 15:29:27 +00:00
2026-01-02 18:39:48 +01:00
2026-01-02 18:39:48 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2026-03-16 17:23:47 +01:00
…
…
…
…
…
…
…