From nobody@FreeBSD.org  Sat Sep 12 17:08:16 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0923E106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 12 Sep 2009 17:08:16 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id E1A8B8FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 12 Sep 2009 17:08:15 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n8CH8FU2020555
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 12 Sep 2009 17:08:15 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n8CH8F6A020530;
	Sat, 12 Sep 2009 17:08:15 GMT
	(envelope-from nobody)
Message-Id: <200909121708.n8CH8F6A020530@www.freebsd.org>
Date: Sat, 12 Sep 2009 17:08:15 GMT
From: Kuan-Chung Chiu <buganini@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] multimedia/audacious segfault with timidity
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         138765
>Category:       ports
>Synopsis:       [patch] multimedia/audacious segfault with timidity
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    oliver
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Sep 12 17:10:06 UTC 2009
>Closed-Date:    Mon Dec 14 16:18:33 UTC 2009
>Last-Modified:  Mon Dec 14 16:18:33 UTC 2009
>Originator:     Kuan-Chung Chiu
>Release:        9.0-CURRENT
>Organization:
N/A
>Environment:
FreeBSD Zeta.twbbs.org 9.0-CURRENT FreeBSD 9.0-CURRENT #0: Sun Sep  6 02:18:48 CST 2009     root@Zeta.twbbs.org:/usr/obj/usr/src/sys/ZETA  i386

>Description:
Zeta# gdb /usr/local/bin/audacious2
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...(no debugging symbols found)...
(gdb) run
Starting program: /usr/local/bin/audacious2 
[New LWP 100130]
[New Thread 49c01140 (LWP 100130)]
[New Thread 49cdb280 (LWP 100216)]
[New Thread 49cda740 (LWP 100226)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 49c01140 (LWP 100130)]
0x4826bda1 in has_case_prefix (haystack=0x0, needle=0x482bc033 "file:/") at gconvert.c:1446
1446	  while (*n && *h &&
(gdb) bt
#0  0x4826bda1 in has_case_prefix (haystack=0x0, needle=0x482bc033 "file:/") at gconvert.c:1446
#1  0x4826c934 in IA__g_filename_from_uri (uri=0x0, hostname=0x0, error=0x0) at gconvert.c:1742
#2  0x48125875 in vfs_file_test (path=0x0, test=G_FILE_TEST_EXISTS) at vfs.c:362
#3  0x4d699f24 in open_file (name=0xbfbfe693 "goemon.cfg") at libtimidity/common.c:57
#4  0x4d6a4cca in read_config_file (name=0xbfbfe693 "goemon.cfg") at libtimidity/timidity.c:89
#5  0x4d6a501a in read_config_file (name=0x4a366970 "/usr/local/lib/timidity/timidity.cfg") at libtimidity/timidity.c:219
#6  0x4d6a5a77 in mid_init (config_file=0x4a366970 "/usr/local/lib/timidity/timidity.cfg") at libtimidity/timidity.c:431
#7  0x4d698e21 in xmmstimid_init () at xmms-timidity.c:104
#8  0x08063744 in plugin_system_init ()
#9  0x0805ac85 in main ()
(gdb)
>How-To-Repeat:
make -C /usr/ports/multimedia/audacious-plugins/ config;
check TIMIDITY
sudo make install
cd ~
audacious2
>Fix:
In common.c, open_file first try to open file directly and return if success, then search in searching paths.
During the direct opening, g_filename_to_uri return 0x0 when file doesnt exist (in pwd), then the NULL path leads to crash.

Adding sanity check before calling vfs_file_test solve problem.

I added a patch file into files/ to solve the problem.

Patch attached with submission follows:

diff -ruN audacious-plugins.orig/files/patch-src-timidity-common.c audacious-plugins/files/patch-src-timidity-common.c
--- audacious-plugins.orig/files/patch-src-timidity-common.c	1970-01-01 08:00:00.000000000 +0800
+++ audacious-plugins/files/patch-src-timidity-common.c	2009-09-13 01:02:51.480171971 +0800
@@ -0,0 +1,11 @@
+--- src/timidity/libtimidity/common.c.orig	2009-09-13 00:44:39.716129871 +0800
++++ src/timidity/libtimidity/common.c	2009-09-13 00:46:40.841815329 +0800
+@@ -54,7 +54,7 @@
+   DEBUG_MSG("Trying to open %s\n", name);
+   fp = NULL;
+   uri = g_filename_to_uri(name, NULL, NULL); 
+-  if (aud_vfs_file_test(uri, G_FILE_TEST_EXISTS)) {
++  if (uri && aud_vfs_file_test(uri, G_FILE_TEST_EXISTS)) {
+     fp = aud_vfs_fopen(uri, OPEN_MODE);
+   }
+   g_free(uri);


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->oliver 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Sat Sep 12 17:10:21 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138765 

From: Buganini <buganini@gmail.com>
To: bug-followup@FreeBSD.org, buganini@gmail.com
Cc:  
Subject: Re: ports/138765: [patch] multimedia/audacious segfault with timidity
Date: Sun, 13 Sep 2009 01:27:13 +0800

 --001636c5c24a550142047364be0b
 Content-Type: text/plain; charset=UTF-8
 
 BTW, this bug has been fixed in upstream, so remove the patch in next
 release, thanks.
 
 --Buganini
 
 --001636c5c24a550142047364be0b
 Content-Type: text/html; charset=UTF-8
 
 BTW, this bug has been fixed in upstream, so remove the patch in next release, thanks.<br><br>--Buganini<br>
 
 --001636c5c24a550142047364be0b--
State-Changed-From-To: open->closed 
State-Changed-By: oliver 
State-Changed-When: Mon Dec 14 16:17:52 UTC 2009 
State-Changed-Why:  
sorry I missed this one :( 
But as far as stated in the PR it should now be fixed in the latest version anyway 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138765 
>Unformatted:
