Index | Thread | Search

From:
Walter Alejandro Iglesias <wai@roquesor.com>
Subject:
Re: mplayer crashes when quiting
To:
landry@openbsd.org, ports@openbsd.org, brad@comstyle.com
Date:
Mon, 10 Nov 2025 20:47:37 +0100

Download raw body.

Thread
On Mon, Nov 10, 2025 at 07:43:28PM +0100, Kirill A. Korinsky wrote:
> On Mon, 10 Nov 2025 12:45:55 +0100,
> Landry Breuil <landry@openbsd.org> wrote:
> > 
> > Le Mon, Nov 10, 2025 at 12:08:13PM +0100, Walter Alejandro Iglesias a écrit :
> > > mplayer seems to play videos fine but when the program exits it prints
> > > this message:
> > >
> > >   MPlayer interrupted by signal 11 in module: uninit_acodec
> > >   - MPlayer crashed by bad usage of CPU/FPU/RAM.
> > >     Recompile MPlayer with --enable-debug and make a 'gdb' backtrace and
> > >     disassembly. Details in DOCS/HTML/en/bugreports_what.html#bugreports_crash.
> > >   - MPlayer crashed. This shouldn't happen.
> > >     It can be a bug in the MPlayer code _or_ in your drivers _or_ in your
> > >     gcc version. If you think it's MPlayer's fault, please read
> > >
> > >
> > > Thread 1 received signal SIGSEGV, Segmentation fault.
> > > 0x00000a9a6fa5b024 in av_freep () from /usr/local/lib/libavutil.so.17.0
> > > (gdb) bt
> > > #0  0x00000a9a6fa5b024 in av_freep () from /usr/local/lib/libavutil.so.17.0
> > > #1  0x00000a984c4e1c04 in ?? ()
> > > #2  0x0000003000000018 in ?? ()
> > > #3  0x0000000000000000 in ?? ()
> > > (gdb) q
> > 
> > can confirm the crash, better trace below, when compiled with the
> > attached diff that disables striping.
> > 
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x00000d1fd0fed024 in av_freep () from /usr/local/lib/libavutil.so.17.0
> > (gdb) bt
> > #0  0x00000d1fd0fed024 in av_freep () from /usr/local/lib/libavutil.so.17.0
> > #1  0x00000d1d742a1c74 in uninit (sh=<optimized out>) at libmpcodecs/ad_ffmpeg.c:201
> > #2  0x00000d1d741d55b1 in uninit_audio (sh_audio=0xd1fd2bf3280) at libmpcodecs/dec_audio.c:326
> > #3  0x00000d1d7416f5fe in uninit_player (mask=7883) at mplayer.c:578
> > #4  0x00000d1d7416f9d7 in exit_player_with_rc (how=EXIT_QUIT, rc=0) at mplayer.c:708
> > #5  0x00000d1d741669ee in run_command (mpctx=0xd1d7430c1f8 <mpctx_s>, cmd=0xd1fd2bd9f00) at command.c:2773
> > #6  0x00000d1d74174555 in main (argc=2, argv=0x743d0318a5b8) at mplayer.c:3999
> > 
> >
> 
> Thanks for the trace. May I ask you to try this diff?

It also works for me.  No crash.

> 
> Index: Makefile
> ===================================================================
> RCS file: /home/cvs/ports/x11/mplayer/Makefile,v
> diff -u -p -r1.336 Makefile
> --- Makefile	28 Oct 2025 09:39:26 -0000	1.336
> +++ Makefile	10 Nov 2025 16:12:41 -0000
> @@ -3,7 +3,7 @@ COMMENT=	movie player supporting many fo
>  V=		20240803
>  FFMPEG_V=	8.0
>  DISTNAME=	mplayer-${V}
> -REVISION=	4
> +REVISION=	5
>  CATEGORIES=	x11 multimedia
>  SITES=		https://comstyle.com/source/
>  EXTRACT_SUFX=	.tar.xz
> Index: patches/patch-libaf_af_lavcac3enc_c
> ===================================================================
> RCS file: /home/cvs/ports/x11/mplayer/patches/patch-libaf_af_lavcac3enc_c,v
> diff -u -p -r1.1 patch-libaf_af_lavcac3enc_c
> --- patches/patch-libaf_af_lavcac3enc_c	21 Oct 2025 13:07:21 -0000	1.1
> +++ patches/patch-libaf_af_lavcac3enc_c	10 Nov 2025 18:24:03 -0000
> @@ -1,21 +1,23 @@
>  Index: libaf/af_lavcac3enc.c
>  --- libaf/af_lavcac3enc.c.orig
>  +++ libaf/af_lavcac3enc.c
> -@@ -101,7 +101,7 @@ static int control(struct af_instance_s *af, int cmd, 
> +@@ -100,8 +100,6 @@ static int control(struct af_instance_s *af, int cmd, 
> +                 s->lavc_actx->sample_rate != af->data->rate ||
>                   s->lavc_actx->bit_rate != bit_rate) {
>   
> -             if (s->lavc_actx->codec)
> +-            if (s->lavc_actx->codec)
>  -                avcodec_close(s->lavc_actx);
> -+                avcodec_free_context(&s->lavc_actx);
>   
>               // Put sample parameters
>               s->lavc_actx->ch_layout.nb_channels = af->data->nch;
> -@@ -158,7 +158,7 @@ static void uninit(struct af_instance_s* af)
> +@@ -157,9 +155,7 @@ static void uninit(struct af_instance_s* af)
> +         af_ac3enc_t *s = af->setup;
>           af->setup = NULL;
>           if(s->lavc_actx) {
> -             if (s->lavc_actx->codec)
> +-            if (s->lavc_actx->codec)
>  -                avcodec_close(s->lavc_actx);
> -+                avcodec_free_context(&s->lavc_actx);
> -             free(s->lavc_actx);
> +-            free(s->lavc_actx);
> ++            avcodec_free_context(&s->lavc_actx);
>           }
>           free(s->pending_data);
> +         free(s);
> Index: patches/patch-libmpcodecs_ad_ffmpeg_c
> ===================================================================
> RCS file: /home/cvs/ports/x11/mplayer/patches/patch-libmpcodecs_ad_ffmpeg_c,v
> diff -u -p -r1.1 patch-libmpcodecs_ad_ffmpeg_c
> --- patches/patch-libmpcodecs_ad_ffmpeg_c	21 Oct 2025 13:07:21 -0000	1.1
> +++ patches/patch-libmpcodecs_ad_ffmpeg_c	10 Nov 2025 18:24:03 -0000
> @@ -1,12 +1,15 @@
>  Index: libmpcodecs/ad_ffmpeg.c
>  --- libmpcodecs/ad_ffmpeg.c.orig
>  +++ libmpcodecs/ad_ffmpeg.c
> -@@ -196,7 +196,7 @@ static void uninit(sh_audio_t *sh)
> +@@ -196,10 +196,9 @@ static void uninit(sh_audio_t *sh)
>   {
>       AVCodecContext *lavc_context = sh->context;
>   
>  -    if (avcodec_close(lavc_context) < 0)
> -+    avcodec_free_context(&lavc_context);
> - 	mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec);
> +-	mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec);
>       av_freep(&lavc_context->opaque);
>       av_freep(&lavc_context->extradata);
> ++    avcodec_free_context(&lavc_context);
> +     av_freep(&lavc_context);
> + }
> + 
> Index: patches/patch-libmpcodecs_vd_ffmpeg_c
> ===================================================================
> RCS file: /home/cvs/ports/x11/mplayer/patches/patch-libmpcodecs_vd_ffmpeg_c,v
> diff -u -p -r1.7 patch-libmpcodecs_vd_ffmpeg_c
> --- patches/patch-libmpcodecs_vd_ffmpeg_c	21 Oct 2025 13:07:21 -0000	1.7
> +++ patches/patch-libmpcodecs_vd_ffmpeg_c	10 Nov 2025 18:24:03 -0000
> @@ -1,7 +1,7 @@
>  Index: libmpcodecs/vd_ffmpeg.c
>  --- libmpcodecs/vd_ffmpeg.c.orig
>  +++ libmpcodecs/vd_ffmpeg.c
> -@@ -511,9 +511,6 @@ static void uninit(sh_video_t *sh){
> +@@ -511,11 +511,9 @@ static void uninit(sh_video_t *sh){
>       }
>   
>       if (avctx) {
> @@ -10,8 +10,11 @@ Index: libmpcodecs/vd_ffmpeg.c
>  -
>           av_freep(&avctx->extradata);
>           av_freep(&avctx->hwaccel_context);
> ++        avcodec_free_context(&avctx);
>       }
> -@@ -1060,8 +1057,10 @@ static mp_image_t *decode(sh_video_t *sh, void *data, 
> + 
> +     avcodec_free_context(&avctx);
> +@@ -1060,8 +1058,10 @@ static mp_image_t *decode(sh_video_t *sh, void *data, 
>   //    mpi->qscale = av_frame_get_qp_table(pic, &mpi->qstride, &mpi->qscale_type);
>       mpi->pict_type=pic->pict_type;
>       mpi->fields = MP_IMGFIELD_ORDERED;
> Index: patches/patch-libmpcodecs_vf_screenshot_c
> ===================================================================
> RCS file: /home/cvs/ports/x11/mplayer/patches/patch-libmpcodecs_vf_screenshot_c,v
> diff -u -p -r1.1 patch-libmpcodecs_vf_screenshot_c
> --- patches/patch-libmpcodecs_vf_screenshot_c	21 Oct 2025 13:07:21 -0000	1.1
> +++ patches/patch-libmpcodecs_vf_screenshot_c	10 Nov 2025 18:24:03 -0000
> @@ -1,12 +1,13 @@
>  Index: libmpcodecs/vf_screenshot.c
>  --- libmpcodecs/vf_screenshot.c.orig
>  +++ libmpcodecs/vf_screenshot.c
> -@@ -279,7 +279,7 @@ static int query_format(struct vf_instance *vf, unsign
> +@@ -279,8 +279,7 @@ static int query_format(struct vf_instance *vf, unsign
>   
>   static void uninit(vf_instance_t *vf)
>   {
>  -    avcodec_close(vf->priv->avctx);
> +-    av_freep(&vf->priv->avctx);
>  +    avcodec_free_context(&vf->priv->avctx);
> -     av_freep(&vf->priv->avctx);
>       if(vf->priv->ctx) sws_freeContext(vf->priv->ctx);
>       av_freep(&vf->priv->pic->data[0]);
> +     av_frame_free(&vf->priv->pic);
> Index: patches/patch-libvo_vo_png_c
> ===================================================================
> RCS file: /home/cvs/ports/x11/mplayer/patches/patch-libvo_vo_png_c,v
> diff -u -p -r1.1 patch-libvo_vo_png_c
> --- patches/patch-libvo_vo_png_c	21 Oct 2025 13:07:21 -0000	1.1
> +++ patches/patch-libvo_vo_png_c	10 Nov 2025 18:24:03 -0000
> @@ -1,21 +1,23 @@
>  Index: libvo/vo_png.c
>  --- libvo/vo_png.c.orig
>  +++ libvo/vo_png.c
> -@@ -126,7 +126,7 @@ config(uint32_t width, uint32_t height, uint32_t d_wid
> +@@ -126,8 +126,7 @@ config(uint32_t width, uint32_t height, uint32_t d_wid
>   
>   
>       if (avctx && png_format != format) {
>  -        avcodec_close(avctx);
> +-        av_freep(&avctx);
>  +        avcodec_free_context(&avctx);
> -         av_freep(&avctx);
>       }
>   
> -@@ -214,7 +214,7 @@ query_format(uint32_t format)
> +     if (!avctx) {
> +@@ -214,8 +213,7 @@ query_format(uint32_t format)
>   }
>   
>   static void uninit(void){
>  -    avcodec_close(avctx);
> +-    av_freep(&avctx);
>  +    avcodec_free_context(&avctx);
> -     av_freep(&avctx);
>       av_freep(&outbuffer);
>       outbuffer_size = 0;
> +     free(png_outdir);
> Index: patches/patch-sub_av_sub_c
> ===================================================================
> RCS file: /home/cvs/ports/x11/mplayer/patches/patch-sub_av_sub_c,v
> diff -u -p -r1.1 patch-sub_av_sub_c
> --- patches/patch-sub_av_sub_c	21 Oct 2025 13:07:21 -0000	1.1
> +++ patches/patch-sub_av_sub_c	10 Nov 2025 18:24:03 -0000
> @@ -1,12 +1,13 @@
>  Index: sub/av_sub.c
>  --- sub/av_sub.c.orig
>  +++ sub/av_sub.c
> -@@ -30,7 +30,7 @@ void reset_avsub(struct sh_sub *sh)
> +@@ -30,8 +30,7 @@ void reset_avsub(struct sh_sub *sh)
>           AVCodecContext *ctx = sh->context;
>           ctx->extradata = NULL;
>           ctx->extradata_size = 0;
>  -        avcodec_close(sh->context);
> +-        av_freep(&sh->context);
>  +        avcodec_free_context(&sh->context);
> -         av_freep(&sh->context);
>       }
>   }
> + 
> 
> 
> -- 
> wbr, Kirill
> 

-- 
Walter