From: Sebastian Ramacher <sramacher@debian.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v3] avcodec/decode: guard against NULL hw_frames_ctx
Date: Sun, 19 Nov 2023 11:10:59 +0100
Message-ID: <ZVnfM5Wj1d21fNzM@ramacher.at> (raw)
In-Reply-To: <1700240583-793-1-git-send-email-dmitry.v.rogozhkin@intel.com>
On 2023-11-17 09:03:03 -0800, Dmitry Rogozhkin wrote:
> Guard against segfault running VLC decoding under msys2 [1]:
>
> Thread 33 received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 37728.0xadd0]
> ff_hwaccel_frame_priv_alloc (avctx=0x6447b00, hwaccel_picture_private=0x65dfd00)
> at libavcodec/decode.c:1848
> 1848 frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
> (gdb) bt
> at libavcodec/decode.c:1848
> at libavcodec/h264_slice.c:208
> first_slice=1) at libavcodec/h264_slice.c:1599
> at libavcodec/h264_slice.c:2130
> at libavcodec/h264dec.c:652
> got_frame=0x646e4b0, avpkt=0x64522c0) at libavcodec/h264dec.c:1048
>
> (gdb) p avctx
> $1 = (AVCodecContext *) 0x6447b00
> (gdb) p avctx->hw_frames_ctx
> $2 = (AVBufferRef *) 0x0
>
> v2: check for free_frame_priv (Hendrik)
> v3: return EINVAL (Christoph Reiter)
>
> See[1]: https://github.com/msys2/MINGW-packages/pull/19050
> Fixes: be07145109 ("avcodec: add AVHWAccel.free_frame_priv callback")
> CC: Lynne <dev@lynne.ee>
> CC: Christoph Reiter <reiter.christoph@gmail.com>
> Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
We have also seen the same issue on Debian unstable with VDPAU playback
in vlc. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1055952. I
can confirm that this patch fixes the issue. Please apply the patch and
backport it to 6.1.
Cheers
> ---
> libavcodec/decode.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index ad39021..50c3995 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1838,17 +1838,25 @@ int ff_copy_palette(void *dst, const AVPacket *src, void *logctx)
> int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private)
> {
> const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel);
> - AVHWFramesContext *frames_ctx;
>
> if (!hwaccel || !hwaccel->frame_priv_data_size)
> return 0;
>
> av_assert0(!*hwaccel_picture_private);
>
> - frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
> - *hwaccel_picture_private = ff_refstruct_alloc_ext(hwaccel->frame_priv_data_size, 0,
> - frames_ctx->device_ctx,
> - hwaccel->free_frame_priv);
> + if (hwaccel->free_frame_priv) {
> + AVHWFramesContext *frames_ctx;
> +
> + if (!avctx->hw_frames_ctx)
> + return AVERROR(EINVAL);
> +
> + *hwaccel_picture_private = ff_refstruct_alloc_ext(hwaccel->frame_priv_data_size, 0,
> + frames_ctx->device_ctx,
> + hwaccel->free_frame_priv);
> + } else {
> + *hwaccel_picture_private = ff_refstruct_allocz(hwaccel->frame_priv_data_size);
> + }
> +
> if (!*hwaccel_picture_private)
> return AVERROR(ENOMEM);
>
> --
> 1.8.3.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-11-19 10:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-14 18:22 [FFmpeg-devel] [PATCH] " Dmitry Rogozhkin
2023-11-14 18:32 ` Hendrik Leppkes
2023-11-15 15:28 ` Rogozhkin, Dmitry V
2023-11-14 19:14 ` [FFmpeg-devel] [PATCH v2] " Dmitry Rogozhkin
2023-11-17 15:41 ` Rogozhkin, Dmitry V
2023-11-17 17:03 ` [FFmpeg-devel] [PATCH v3] " Dmitry Rogozhkin
2023-11-19 10:10 ` Sebastian Ramacher [this message]
2023-11-19 15:29 ` Hendrik Leppkes
2023-11-21 4:45 ` Rogozhkin, Dmitry V
2023-11-21 4:37 ` [FFmpeg-devel] [PATCH v4] avcodec/decode: validate hw_frames_ctx when AVHWAccel.free_frame_priv is used Dmitry Rogozhkin
[not found] ` <1700541472-12254-1-git-send-email-dmitry.v.rogozhkin@intel.com-NjkA62m----9>
2023-11-21 5:17 ` Lynne
2023-11-21 6:02 ` Rogozhkin, Dmitry V
2023-11-22 4:08 ` Lynne
2023-11-21 5:57 ` [FFmpeg-devel] [PATCH v5] " Dmitry Rogozhkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZVnfM5Wj1d21fNzM@ramacher.at \
--to=sramacher@debian.org \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git