Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 91328 - media-video/mkvtoolnix-1.4.2 - mmg segfault whenever the "add" button is pressed
Summary: media-video/mkvtoolnix-1.4.2 - mmg segfault whenever the "add" button is pressed
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Gentoo Media-video project
URL:
Whiteboard:
Keywords: Inclusion
Depends on: 98089
Blocks: 92499
  Show dependency tree
 
Reported: 2005-05-03 09:44 UTC by will_luan
Modified: 2005-09-04 11:58 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description will_luan 2005-05-03 09:44:32 UTC
After upgrading to mkvtoolnix-1.4.2, I discovered that mmg, a GUI frontend that come with the package, would crash whenever the "add" button is pressed. I looked into the source code, and after some debugging, found out the problem is caused by a function call in the file src/mmg/tab_input.cpp:
  media_files.Printf(...)
which could try access beyond assigned memory address and consequently effect a segfault. Until wxGTK provides a safer wxString methed, "asprintf()" is a better choice, as it is less prone to memory access error. Here is a patch that fixed the bug:

--- tab_input.cpp.orig  2005-03-19 03:02:04.000000000 -0800
+++ tab_input.cpp       2005-05-02 16:53:31.000000000 -0700
@@ -13,6 +13,9 @@
    Written by Moritz Bunkus <moritz@bunkus.org>.
 */

+#include<stdio.h>
+#include<stdlib.h>
+
 #include <errno.h>

 #include <algorithm>
@@ -674,7 +677,7 @@
     vector<wxString> extensions;
     wxString s_exts;
     int e;
-
+
     if ((wxString(file_types[ft].title).Find(wxT("FLAC")) >= 0) &&
         (capabilities[wxT("FLAC")] != wxT("true")))
       continue;
@@ -708,8 +711,13 @@
     a_exts += wxString::Format(wxT("*.%s"), all_extensions[ae].c_str());
   }

-  media_files.Printf(wxT("Media files (%s)|%s%s|%s"), a_exts.c_str(),
-                     a_exts.c_str(), rest.c_str(), wxT(ALLFILES));
+  char* m_files;
+  if (asprintf(&m_files, "Media files (%.30s...)|%s%s|%s", a_exts.c_str(),
+       a_exts.c_str(), rest.c_str(), wxT(ALLFILES)) > -1) {
+      media_files = wxT(m_files);
+      free(m_files);
+  }
+
   wxFileDialog dlg(NULL,
                    append ? wxT("Choose an input file to append") :
                    wxT("Chose an input file to add"),

Reproducible: Always
Steps to Reproduce:
1. Build the package:
   USE='bzip2 flac lzo gxwindows' emerge '=mkvtoolnix-1.4.2'
2. Run "mmg"
3. Click on the "add" button on the "Input" tab.

Actual Results:  
"mmg" would segfault.

Expected Results:  
A dialog box for file selection should pop up.

The package "mkvtoolnix" was built on an amd64 system running 2.6.10-gentoo-r6.
gcc is set to the profile "x86_64-pc-linux-gnu-3.4.3".
Comment 1 Daniel Webert 2005-06-13 06:38:13 UTC
can we fix this plz?
Comment 2 Georgi Georgiev 2005-07-10 21:37:19 UTC
I have the same problem, but the proper fix I believe is this:

--- /usr/portage/media-video/mkvtoolnix/mkvtoolnix-1.4.2-r1.ebuild     
2005-06-03 19:55:45.000000000 +0900
+++ ./mkvtoolnix-1.4.2-r1.ebuild        2005-07-11 13:20:50.000000000 +0900
@@ -44,6 +44,7 @@
 
        epatch ${FILESDIR}/${PN}-configure-checks.patch
        epatch ${WORKDIR}/${P}-nowarns.patch
+       sed -i -e "s:wx-config :${WX_CONFIG} :" configure.in
        ./autogen.sh
 }
 

It's just that wx-config is currently hard-coded in configure.in (and
configure), and it defaults to wxGTK-2.4 if 2.4 is installed.  Or, it fails if
2.4 is not installed (well, it says that you don't have wx-config and skips the
gui).

It would also be nice to see a version bump to mkvtoolnix-1.5.0.

The pkg_setup portion could be improved like this:

@@ -31,7 +30,11 @@
                if ! use gtk2 ; then
                        need-wxwidgets gtk || die "You must compile wxGTK
without wx_nogtk useflag."
                else
-                       need-wxwidgets gtk2 || die "You must compile wxGTK with
gtk2 useflag."
+                       if use unicode; then
+                               need-wxwidgets unicode || die "You must compile
wxGTK with unicode useflag."
+                       else
+                               need-wxwidgets gtk2 || die "You must compile
wxGTK with gtk2 useflag."
+                       fi
                fi
        elif use gtk2; then
                einfo "You won't have gtk2 support as you requested not to use
wxwindows."

Though I have no idea how the -ansi and -unicode versions of wxGTK differ, but I
have USE=unicode and it would be nice to have mmg link against the unicode
version of wxGTK.
Comment 3 Diego Elio Pettenò (RETIRED) gentoo-dev 2005-09-03 03:26:45 UTC
1.5.5 fixes the problem. 
Comment 4 Georgi Georgiev 2005-09-04 11:58:36 UTC
(In reply to comment #3)
> 1.5.5 fixes the problem. 

Please, take a look at my comment #2. The location to wx-config is hard-coded in
the configure script, hence the sed.

I just emerged 1.5.5 from the official portage tree, and I did not get mmg
installed. I only have wxGTK 2.6.1 on my system (I don't have wxGTK 2.4). I am
now emerging with the patch from comment #2 and it seems to be going fine:

$ diff -u 4849-mkvtoolnix-1.5.5.log 4850-mkvtoolnix-1.5.5.log  | head -n 30
--- 4849-mkvtoolnix-1.5.5.log   2005-09-05 03:42:21.000000000 +0900
+++ 4850-mkvtoolnix-1.5.5.log   2005-09-05 03:57:24.000000000 +0900
@@ -1,4 +1,5 @@
- * Using /usr/lib64/wx/config/gtk2-ansi-release-2.6
+QA Notice: USE Flag 'unicode' not in IUSE for media-video/mkvtoolnix-1.5.5
+ * Using /usr/lib64/wx/config/gtk2-unicode-release-2.6
 >>> Unpacking source...
 >>> Unpacking mkvtoolnix-1.5.5.tar.bz2 to /var/tmp/portage/mkvtoolnix-1.5.5/work
 >>> Source unpacked.
@@ -85,7 +86,7 @@
 checking bzlib.h usability... yes
 checking bzlib.h presence... yes
 checking for bzlib.h... yes
-checking for wxWidgets... no: wx-config was not found
+checking for wxWidgets... 2.6.1 ok
 configure: creating ./config.status
 config.status: creating Makefile
 config.status: creating avilib-0.6.10/Makefile
@@ -102,8 +103,8 @@
 config.status: creating config.h
 
 *** The mkvtoolnix configuration is complete.
-***   Optional features that are built:  FLAC audio (1.1.1 or newer); LZO
compression; BZ2 compression
-***   Optional features that are NOT built:  GUIs
+***   Optional features that are built:  FLAC audio (1.1.1 or newer); LZO
compression; BZ2 compression; GUIs
+***   Optional features that are NOT built: 
      CXX  src/merge/cluster_helper.cpp
 src/merge/cluster_helper.cpp: In member function `void
cluster_helper_c::add_packet(packet_cptr)':
 src/merge/cluster_helper.cpp:105: warning: long long int format, int64_t arg
(arg 3)