Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Jul 2007 10:25:33 -0400
From:      Michael Johnson <ahze@ahze.net>
To:        Gary Palmer <gpalmer@freebsd.org>
Cc:        freebsd-multimedia@FreeBSD.org
Subject:   Re: ports/113922: multimedia/ffmpeg segfaults on start
Message-ID:  <3B5B9842-474E-4BBD-8F98-A9B6803EA0DA@ahze.net>
In-Reply-To: <200707130300.l6D30IbC060392@freefall.freebsd.org>
References:  <200707130300.l6D30IbC060392@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--Apple-Mail-2--128896636
Content-Type: multipart/mixed; boundary=Apple-Mail-1--128896662


--Apple-Mail-1--128896662
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=ISO-8859-1;
	delsp=yes;
	format=flowed


On Jul 13, 2007, at 3:00 AM, Gary Palmer wrote:

> The following reply was made to PR ports/113922; it has been noted =20
> by GNATS.
>
> From: Gary Palmer <gpalmer@freebsd.org>
> To: bug-followup@FreeBSD.org
> Cc:
> Subject: Re: ports/113922: multimedia/ffmpeg segfaults on start
> Date: Fri, 13 Jul 2007 03:40:02 +0100
>
>  I also experienced the crash.  I tracked it down to ffmpeg source =20
> code.
>
>  Program received signal SIGSEGV, Segmentation fault.
>  [Switching to Thread 0x8480000 (LWP 100306)]
>  0x48852af7 in __vfprintf () from /lib/libc.so.6
>  (gdb) bt
>  #0  0x48852af7 in __vfprintf () from /lib/libc.so.6
>  #1  0x488536f1 in vfprintf () from /lib/libc.so.6
>  #2  0x0805fd7d in log_callback_help (ptr=3D0x0, level=3D1, =
fmt=3D0x837b39c
>  "T=B27\b",
>      vl=3D0x82c4b7e =
"\203=C4\030[=C3\220S\203=EC\b\215D$\034P=FFt$\034=FFt$\034=E8")
>      at ffmpeg.c:3735
>  #3  0x082c4b7e in av_vlog (avcl=3D0x848e010, level=3D137788800,
>      fmt=3D0x837b39c "T=B27\b", vl=3D0x82c4baa "\203=C4\030[=C3\220=E8")=
 at =20
> log.c:65
>  #4  0x082c4baa in av_log (avcl=3D0x848e010, level=3D0, fmt=3D0x837b39c =
=20
> "T=B27\b")
>      at log.c:58
>  #5  0x081a9c13 in av_opt_show (obj=3D0x8477130, av_log_obj=3D0x0) at =20=

> opt.c:335
>  #6  0x0805fe93 in show_help () at ffmpeg.c:3771
>  #7  0x08060d03 in main (argc=3D1, argv=3D0xbfbfe808) at ffmpeg.c:3798
>
>  Notice the fmt parameters are garbage from 4 upwards
>
>  #6  0x0805fe93 in show_help () at ffmpeg.c:3771
>  3771        av_opt_show(sws_opts, NULL);
>
>  Looking through the code, sws_opts is populated at ffmpeg.c in main=20=

> () at
>  line 3794 with a call to sws_getContext
>
>  The real fun is that the ffmpeg code has TWO definitions for
>  sws_getContext when you have --enable-swscaler passed to configure
>  (which is the default for the port).  One is defined in
>  libavcodec/imgresample.c and the other in libswscale/swscale.c
>

>  At least on my system, the linker defaulted to the version in =20
> libavcodec
>  which leads to the SIGSEGV.  Putting "#if 0" around the =20
> definitions for
>  sws_getContext, sws_freeContext and sws_scale in
>  libavcodec/imgresample.c appears to stop the SIGSEGV for me.
>
>  Alternatively, deleting the files/patch-libavcodec_Makefile patch =20
> file
>  appears to also stop the coredump.
>

I don't recall why we needed this patch, but I don't think it's =20
needed anymore

Please test this patch.


--Apple-Mail-1--128896662
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name=ffmpeg.diff
Content-Disposition: attachment;
	filename=ffmpeg.diff

diff -ruN --exclude=.svn ffmpeg.orig/Makefile ffmpeg/Makefile
--- ffmpeg.orig/Makefile	2007-06-12 05:00:26.000000000 -0400
+++ ffmpeg/Makefile	2007-07-13 09:17:27.000000000 -0400
@@ -6,8 +6,7 @@
 #
 
 PORTNAME=	ffmpeg
-DISTVERSION=	2007-05-30
-PORTREVISION=	1
+DISTVERSION=	2007-07-12
 CATEGORIES=	multimedia audio ipv6 net
 MASTER_SITES=	${MASTER_SITE_LOCAL}
 MASTER_SITE_SUBDIR=	ahze
@@ -19,13 +18,16 @@
 USE_BZIP2=	yes
 USE_GMAKE=	yes
 WANT_SDL=	yes
+
+.include <bsd.port.pre.mk>
+
 CONFIGURE_ARGS=	--cc="${CC}" --prefix="${PREFIX}" \
 		--make="${GMAKE}" \
 		--disable-debug \
 		--enable-memalign-hack \
 		--enable-shared \
 		--enable-pp \
-		--extra-cflags="-fPIC -DPIC ${CFLAGS} -I${LOCALBASE}/include" \
+		--extra-cflags="${CFLAGS} -I${LOCALBASE}/include" \
 		--extra-ldflags="-L${LOCALBASE}/lib" \
 		--extra-libs="${PTHREAD_LIBS}" \
 		--enable-gpl \
@@ -37,7 +39,7 @@
 PLIST_SUB=	SHLIB_VER=${SHLIB_VER}
 USE_LDCONFIG=	yes
 
-FFMPEG_MAN1=	ffmpeg.1
+MAN1+=	ffmpeg.1 ffserver.1
 
 ##
 DOC_FILES=	COPYING Changelog README
@@ -47,12 +49,6 @@
 		hooks.html optimization.txt
 PORTDOCS=	*
 
-.include <bsd.port.pre.mk>
-
-.if ${ARCH}=="amd64"
-EXTRA_PATCHES=	${PATCHDIR}/amd64-patch
-.endif
-
 ## sse hardware vector support
 .if (defined(MACHINE_CPU) && ${MACHINE_CPU:Msse} == "sse")
 WITH_BUILTIN_VECTOR=	yes
@@ -92,14 +88,13 @@
 CONFIGURE_ARGS+=	--enable-libfaac
 .endif
 ## faad
-.ifdef(WITH_FAAD) || exists(${LOCALBASE}/lib/libfaad.so)
+.ifndef(WITHOUT_FAAD) || exists(${LOCALBASE}/lib/libfaad.so)
 LIB_DEPENDS+=		faad.0:${PORTSDIR}/audio/faad
 
 CONFIGURE_ARGS+=	--enable-libfaad \
 			--enable-libfaadbin
 .endif
 USE_RC_SUBR=		ffserver
-FFMPEG_MAN1+=		ffserver.1
 
 #### BROKEN LIST #####
 WITHOUT_THEORA=	yes
@@ -132,8 +127,6 @@
 .ifdef(WITH_SDL) || ${HAVE_SDL:Msdl}
 USE_SDL+=	sdl
 
-FFMPEG_MAN1+=	ffplay.1
-
 PLIST_FILES+=	bin/ffplay
 .else
 CONFIGURE_ARGS+=	--disable-ffplay
@@ -156,7 +149,7 @@
 .ifdef(WITH_X264) || exists(${LOCALBASE}/lib/libx264.so)
 LIB_DEPENDS+=		x264.50:${PORTSDIR}/multimedia/x264
 
-CONFIGURE_ARGS+=	--enable-x264
+CONFIGURE_ARGS+=	--enable-libx264
 .endif
 ## builtin vector, requires mmx
 .if !defined(WITHOUT_BUILTIN_VECTOR) && defined(WITH_BUILTIN_VECTOR)
@@ -179,11 +172,7 @@
 .ifdef(WITH_XVID) || exists(${LOCALBASE}/lib/libxvidcore.so)
 LIB_DEPENDS+=		xvidcore.4:${PORTSDIR}/multimedia/xvid
 
-CONFIGURE_ARGS+=	--enable-xvid
-.endif
-
-.ifndef(NOPORTDOCS)
-MAN1=	${FFMPEG_MAN1}
+CONFIGURE_ARGS+=	--enable-libxvid
 .endif
 
 pre-everything::
@@ -239,7 +228,7 @@
 
 post-patch:
 # Faad compat
-	@${REINPLACE_CMD} -e 's|faacD|NeAACD|' ${WRKSRC}/libavcodec/faad.c
+	@${REINPLACE_CMD} -e 's|faacD|NeAACD|' ${WRKSRC}/libavcodec/libfaad.c
 # {C,LD}FLAGS safeness
 # fix x264 math, use correct log base 2 from math(3)
 .if ${OSVERSION} <= 601000
@@ -312,10 +301,7 @@
 		-e 's|^(CONFIG_LIBTHEORA).*$$|\1=no|' \
 		${WRKSRC}/config.mak
 .endif
-# shared libraries PIC
-	@${REINPLACE_CMD} -E \
-		-e 's|^(PIC[[:space:]]*=.*)$$|\1 -fpic -fPIC -DPIC|' \
-		${WRKSRC}/config.mak
+
 post-install:
 	${INSTALL_DATA} ${WRKSRC}/doc/ffserver.conf ${PREFIX}/etc/ffserver.conf-dist
 	if [ ! -f ${PREFIX}/etc/ffserver.conf ]; then \
diff -ruN --exclude=.svn ffmpeg.orig/distinfo ffmpeg/distinfo
--- ffmpeg.orig/distinfo	2007-06-11 22:06:48.000000000 -0400
+++ ffmpeg/distinfo	2007-07-13 09:17:27.000000000 -0400
@@ -1,3 +1,3 @@
-MD5 (ffmpeg-2007-05-30.tar.bz2) = 85d6f1a5657ca9c7730dac76c1cca883
-SHA256 (ffmpeg-2007-05-30.tar.bz2) = fa2237b2852ea8f01b329863f9b07f72865a1f58af5d001904d67f974ab0e18b
-SIZE (ffmpeg-2007-05-30.tar.bz2) = 2256282
+MD5 (ffmpeg-2007-07-12.tar.bz2) = 6f055a17766e7d6a044281ea4a43c481
+SHA256 (ffmpeg-2007-07-12.tar.bz2) = 7abbb87ec7a8ae9ea0ec2e0ad6138d60406e9ef3f1ab6293af98d662276c6210
+SIZE (ffmpeg-2007-07-12.tar.bz2) = 2277468
diff -ruN --exclude=.svn ffmpeg.orig/files/amd64-patch ffmpeg/files/amd64-patch
--- ffmpeg.orig/files/amd64-patch	2007-05-25 13:07:36.000000000 -0400
+++ ffmpeg/files/amd64-patch	1969-12-31 19:00:00.000000000 -0500
@@ -1,55 +0,0 @@
-$OpenBSD: patch-libavcodec_mpegvideo_c,v 1.1 2007/01/23 09:34:45 robert Exp $
---- libavcodec/mpegvideo.c.orig	Sat Dec 23 05:05:36 2006
-+++ libavcodec/mpegvideo.c	Tue Jan  2 18:22:01 2007
-@@ -4837,7 +4837,7 @@ static int pre_estimate_motion_thread(AV
- static int estimate_motion_thread(AVCodecContext *c, void *arg){
-     MpegEncContext *s= arg;
- 
--    ff_check_alignment();
-+    /*ff_check_alignment();*/
- 
-     s->me.dia_size= s->avctx->dia_size;
-     s->first_slice_line=1;
-@@ -4865,7 +4865,7 @@ static int mb_var_thread(AVCodecContext 
-     MpegEncContext *s= arg;
-     int mb_x, mb_y;
- 
--    ff_check_alignment();
-+    /*ff_check_alignment();*/
- 
-     for(mb_y=s->start_mb_y; mb_y < s->end_mb_y; mb_y++) {
-         for(mb_x=0; mb_x < s->mb_width; mb_x++) {
-@@ -4914,7 +4914,7 @@ static int encode_thread(AVCodecContext 
-     PutBitContext pb[2], pb2[2], tex_pb[2];
- //printf("%d->%d\n", s->resync_mb_y, s->end_mb_y);
- 
--    ff_check_alignment();
-+    /*ff_check_alignment();*/
- 
-     for(i=0; i<2; i++){
-         init_put_bits(&pb    [i], bit_buf    [i], MAX_MB_BYTES);
---- libavcodec/dsputil.c.orig	Wed Apr 18 09:42:55 2007
-+++ libavcodec/dsputil.c	Wed Apr 18 10:16:01 2007
-@@ -3814,6 +3814,7 @@
-     for(i=0; i<64; i++) inv_zigzag_direct16[ff_zigzag_direct[i]]= i+1;
- }
- 
-+/*
- int ff_check_alignment(void){
-     static int did_fail=0;
-     DECLARE_ALIGNED_16(int, aligned);
-@@ -3832,12 +3833,12 @@
-     }
-     return 0;
- }
--
-+*/
- void dsputil_init(DSPContext* c, AVCodecContext *avctx)
- {
-     int i;
- 
--    ff_check_alignment();
-+    /*ff_check_alignment();*/
- 
- #ifdef CONFIG_ENCODERS
-     if(avctx->dct_algo==FF_DCT_FASTINT) {
diff -ruN --exclude=.svn ffmpeg.orig/files/patch-configure ffmpeg/files/patch-configure
--- ffmpeg.orig/files/patch-configure	2007-06-11 22:06:49.000000000 -0400
+++ ffmpeg/files/patch-configure	2007-07-13 09:17:27.000000000 -0400
@@ -1,5 +1,5 @@
---- configure.orig	Sun May 27 12:31:02 2007
-+++ configure	Wed May 30 21:50:21 2007
+--- configure.orig	2007-07-08 13:47:15.000000000 -0400
++++ configure	2007-07-09 12:37:09.000000000 -0400
 @@ -210,11 +210,11 @@
  
  # "tr '[a-z]' '[A-Z]'" is a workaround for Solaris tr not grokking "tr a-z A-Z"
@@ -14,7 +14,7 @@
  }
  
  set_all(){
-@@ -1020,15 +1020,9 @@
+@@ -992,15 +992,9 @@
      enable fast_unaligned
    ;;
    x86_64|amd64)
@@ -32,30 +32,20 @@
    ;;
    # armv4l is a subset of armv[567]*l
    arm|armv[4567]*l)
-@@ -1781,14 +1775,14 @@
- # not all compilers support -Os
- test "$optimize" = "small" && check_cflags -Os
- 
--if enabled optimize; then
+@@ -1734,12 +1728,6 @@
+     check_cflags -Os            # not all compilers support -Os
+     optimize="small"
+ elif enabled optimize; then
 -    if test -n "`$cc -v 2>&1 | grep xlc`"; then
 -        add_cflags  "-O5"
 -        add_ldflags "-O5"
 -    else
 -        add_cflags "-O3"
 -    fi
--fi
-+#if enabled optimize; then
-+#    if test -n "`$cc -v 2>&1 | grep xlc`"; then
-+#        add_cflags  "-O5"
-+#        add_ldflags "-O5"
-+#    else
-+#        add_cflags "-O3"
-+#    fi
-+#fi
+ fi
  
  # PIC flags for shared library objects where they are needed
- if enabled shared; then
-@@ -1996,15 +1990,15 @@
+@@ -1927,15 +1915,15 @@
  if enabled shared; then
    echo "BUILD_SHARED=yes" >> config.mak
    echo "PIC=-fPIC -DPIC" >> config.mak
@@ -76,7 +66,7 @@
    echo "SWSVERSION=$sws_version" >> config.mak
    echo "SLIBNAME=${SLIBNAME}" >> config.mak
    echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
-@@ -2039,7 +2033,7 @@
+@@ -1969,7 +1957,7 @@
  
  echo "SRC_PATH=\"$source_path\"" >> config.mak
  echo "SRC_PATH_BARE=$source_path" >> config.mak
@@ -85,7 +75,7 @@
  
  # Apparently it's not possible to portably echo a backslash.
  if enabled asmalign_pot; then
-@@ -2119,8 +2113,8 @@
+@@ -2047,8 +2035,8 @@
  Version: $version
  Requires: $requires
  Conflicts:
@@ -96,7 +86,7 @@
  EOF
  }
  
-@@ -2143,7 +2137,8 @@
+@@ -2071,7 +2059,8 @@
  Requires: $requires
  Conflicts:
  Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
diff -ruN --exclude=.svn ffmpeg.orig/files/patch-libavcodec_Makefile ffmpeg/files/patch-libavcodec_Makefile
--- ffmpeg.orig/files/patch-libavcodec_Makefile	2007-05-25 13:07:36.000000000 -0400
+++ ffmpeg/files/patch-libavcodec_Makefile	1969-12-31 19:00:00.000000000 -0500
@@ -1,12 +0,0 @@
---- libavcodec/Makefile.orig	Thu May  3 08:50:33 2007
-+++ libavcodec/Makefile	Thu May  3 08:50:42 2007
-@@ -293,9 +293,7 @@
- 
- OBJS-$(HAVE_XVMC_ACCEL)                += xvmcvideo.o
- 
--ifneq ($(CONFIG_SWSCALER),yes)
- OBJS += imgresample.o
--endif
- 
- # processor-specific code
- ifeq ($(TARGET_MMX),yes)
diff -ruN --exclude=.svn ffmpeg.orig/pkg-plist ffmpeg/pkg-plist
--- ffmpeg.orig/pkg-plist	2007-06-11 22:06:48.000000000 -0400
+++ ffmpeg/pkg-plist	2007-07-13 09:17:27.000000000 -0400
@@ -6,6 +6,7 @@
 include/ffmpeg/avcodec.h
 include/ffmpeg/avformat.h
 include/ffmpeg/avio.h
+include/ffmpeg/avstring.h
 include/ffmpeg/avutil.h
 include/ffmpeg/base64.h
 include/ffmpeg/common.h
@@ -37,7 +38,7 @@
 lib/libavutil.a
 lib/libavutil.so
 lib/libavutil.so.%%SHLIB_VER%%
-lib/libavutil.so.49.4.0
+lib/libavutil.so.49.4.1
 lib/libpostproc.a
 lib/libpostproc.so
 lib/libpostproc.so.%%SHLIB_VER%%

--Apple-Mail-1--128896662
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	delsp=yes;
	format=flowed


Michael


>  I do not have enough experience with this port to know if either  
> option
>  has bad side effects
>
>
>
> _______________________________________________
> freebsd-multimedia@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-multimedia
> To unsubscribe, send any mail to "freebsd-multimedia- 
> unsubscribe@freebsd.org"


--Apple-Mail-1--128896662--

--Apple-Mail-2--128896636
content-type: application/pgp-signature; x-mac-type=70674453;
	name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iD8DBQFGl4tdn4uqfTwEb9YRAoLrAJ9eawJA2zMPUxaKkBcI+d6O7LMN2QCgqRFo
5ZWhRTAfPta0vVbXGniQrgc=
=GIRT
-----END PGP SIGNATURE-----

--Apple-Mail-2--128896636--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B5B9842-474E-4BBD-8F98-A9B6803EA0DA>