Bug#331653: Patch for #331653: xmms segfaults when browsing an audio CD

2005-10-08 Thread David Moreno Garza
On Fri, 2005-10-07 at 20:12 +0200, Knut Auvor Grythe wrote:
  Actually, the same code is working on Gentoo. I had the chance
  yesterday, to make a Debian package with the Gentoo ebuild patched
  sources (without differences between libxmms/dirbrowser.c and
  xmms/prefswin.c, between others) and it failed too. But on a Gentoo
  system, their patched sources are definitively working.
 
 I forgot to mention that I do not experience the segfault on amd64, only
 when I run a 32 bit xmms in a chroot. There are probably some cases
 where the segfault does not happen, like on gentoo and on 64-bit debian.
 But that does not change the fact that the code is flawed.

The Gentoo system where I checked it was, indeed an AMD64 platform.
Trying to reproduce the bug on a 32 bits Gentoo system was successful.
The segfault also happened there.

Thanks for your work and research, Knut.

--
David Moreno Garza [EMAIL PROTECTED]   |  http://www.damog.net/
   [EMAIL PROTECTED]  |  GPG: C671257D
  Si no vuelves por que no quieres, si no por que no tienes pa'l pasaje.



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#331653: Patch for #331653: xmms segfaults when browsing an audio CD

2005-10-07 Thread Knut Auvor Grythe
I've found the source of this problem. I was going to path it, but then
I had a closer look and decided not to. The problem is in
debian/patches/19_all_play_audiocd, and it is easily patched with the
information I will provide in this mail. However, you shouldn't do it.

The proper solution is to delete debian/patches/19_all_play_audiocd.

19_all_play_audiocd is a complete WTF, and should never have been
applied. I'll give you the short summary first, and the long and boring
one afterwards:

 * The UI is completely wrong
 * The code is buggy (obviously)
 * It provides basically no new functionality and only creates extra
   work for the maintainer

Long description: The patch includes the tab CD Audio in Preferences.
This looks like a pretty wierd place to put it if you ask me, I would
expect this setting to be in the settings of the input plugin. And wait
a second, it is! Actually, for the Play - AudioCD menu item to work,
both the directories must be set to the same thing! This is of course
completely horrible from a usability point of view.

The Play - CD Audio menu item itself is also from the patch, and is
in fact the only real functionality it provides. This menu button does
the same thing as pressing Play - Play Directory and selecting the
directory would do. This only serves to make people think there's
something different with audio CDs. There isn't, they work just as
normal directories. The menu item is only creating confusion.

Okay, over to the code. In xmms/prefswin.c there is a function
prefswin_audiocd_browse_cb (added by 19_all_play_audiocd). I'll quote it
here with numbered lines:

1   static gint prefswin_audiocd_browse_cb(GtkWidget * w, gpointer data)
2   {
3  GtkWidget *prefswin_audiocd_browser;
4  prefswin_audiocd_browser = xmms_create_dir_browser(_(Select directory 
to add:), gtk_entry_get_text(GTK_ENTRY(prefswin_audiocd_cddadirectory)), 
GTK_SELECTION_SINGLE, prefswin_audiocd_browse_handler);
5  gtk_signal_connect(GTK_OBJECT(prefswin_audiocd_browser), destroy, 
GTK_SIGNAL_FUNC(gtk_widget_destroyed), prefswin_audiocd_browser);
6  gtk_window_set_transient_for(GTK_WINDOW(prefswin_audiocd_browser), 
GTK_WINDOW(prefswin));
7  gtk_widget_show(prefswin_audiocd_browser);
8  return (TRUE);
9   }

Notice that *prefswin_audiocd_browser declared in line 3 is local to the
function. When I removed the gtk_signal_connect in line 5, everything
seems to work fine. I found no good docs for GTK 1.x on this, but it's
probably about the same in 2.x I hope. According to
http://developer.gimp.org/api/2.0/gtk/GtkWidget.html#gtk-widget-destroyed
gtk_widget_destroyed sets *widget_pointer to NULL if widget_pointer !=
NULL. [...] Useful for example to avoid multiple copies of the same
dialog.

Looking around the source, it seems gtk_widget_destroyed is used mostly
on global variables, which makes sense for detecting if the window is
already open and just stashed away somewhere. Currently you can open an
infinite amount of identical windows from the Browse button. The
solution to this is declaring *prefswin_audiocd_browser outside the
function, and wrapping the entire function body in an 
  if (!prefswin_audiocd_browser) { /* body */ }. 
This is how it is done in all other windows in XMMS using
xmms_create_dir_browser.

As a sidenote, returning int from this function is also wierd. All other
*_cb functions return void, but this one returns TRUE unconditionally. I
don't know why, but suspect incompetence.

The maintainer hell part is pretty obvious. Today there are 29 patches
in debian/patches, quite a few of then weird stuff nobody asked for.
Take for instance 12_all_sortbytime, which sorts the playlist after the
length of the tracks. Who on earth would want that? Next time the package is
updated from upstream, most of these patches will fail. The poor
maintainer will have to apply almost every patch manually. My guess is
that it will not be very fun. The effect in the long run will probably
be that it will not be very tempting to update the source from upstream,
in practise creating a fork.

That being said, removing the patch now will probably force you to
re-apply patch 20 to 51 manually. It might be a good idea to just update
the entire thing from CVS first, since that will be about the same
amount of work and will probably fix a few other bugs as well. For
instance I hear rumors on IRC about an accidentally shuffled enum in the
CVS snapshot used in the current package. It will also add functionality
I'm waiting for ;o)

-- 
Knut Auvor Grythe


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#331653: Patch for #331653: xmms segfaults when browsing an audio CD

2005-10-07 Thread David Moreno Garza
On Fri, 2005-10-07 at 10:58 +0200, Knut Auvor Grythe wrote:
 I've found the source of this problem.

Actually, the same code is working on Gentoo. I had the chance
yesterday, to make a Debian package with the Gentoo ebuild patched
sources (without differences between libxmms/dirbrowser.c and
xmms/prefswin.c, between others) and it failed too. But on a Gentoo
system, their patched sources are definitively working.

--
David Moreno Garza [EMAIL PROTECTED]   |  http://www.damog.net/
   [EMAIL PROTECTED]  |  GPG: C671257D
  Imagine a large red swirl here.



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#331653: Patch for #331653: xmms segfaults when browsing an audio CD

2005-10-07 Thread Knut Auvor Grythe
On Fri, Oct 07, 2005 at 12:12:29PM -0500, David Moreno Garza wrote:
 I've found the source of this problem.
 
 Actually, the same code is working on Gentoo. I had the chance
 yesterday, to make a Debian package with the Gentoo ebuild patched
 sources (without differences between libxmms/dirbrowser.c and
 xmms/prefswin.c, between others) and it failed too. But on a Gentoo
 system, their patched sources are definitively working.

I forgot to mention that I do not experience the segfault on amd64, only
when I run a 32 bit xmms in a chroot. There are probably some cases
where the segfault does not happen, like on gentoo and on 64-bit debian.
But that does not change the fact that the code is flawed.

-- 
Knut Auvor Grythe


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]