From nobody@FreeBSD.org  Tue Sep 20 10:51:51 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E444416A41F
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 20 Sep 2005 10:51:51 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 94D5643D46
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 20 Sep 2005 10:51:51 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j8KAppNn081465
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 20 Sep 2005 10:51:51 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j8KApp1g081464;
	Tue, 20 Sep 2005 10:51:51 GMT
	(envelope-from nobody)
Message-Id: <200509201051.j8KApp1g081464@www.freebsd.org>
Date: Tue, 20 Sep 2005 10:51:51 GMT
From: Fred Wheeler <fred.s.wheeler@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: port audio/vsound vsound.c fix to prevent abort
X-Send-Pr-Version: www-2.3

>Number:         86365
>Category:       ports
>Synopsis:       port audio/vsound vsound.c fix to prevent abort
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 20 11:00:23 GMT 2005
>Closed-Date:    Mon Oct 03 22:25:33 GMT 2005
>Last-Modified:  Mon Oct 03 22:25:33 GMT 2005
>Originator:     Fred Wheeler
>Release:        FreeBSD 5.4-RELEASE i386
>Organization:
none
>Environment:
System: FreeBSD mobile.earthlink.net 5.4-RELEASE FreeBSD 5.4-RELEASE #0: Sun May 8 10:21:06 UTC 2005 root@harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
>Description:
vsound-0.6 seems to have a bug that causes a program run with vsound to bus
error if that program opens any file.  I see the same problem in the vsound-0.6
source and the audio/vsound port.  The problem is with the type given to
va_arg.  gcc notices the problem and suggests a fix that works for me.


>How-To-Repeat:

The native audio/vsound port led to a Bus error no matter how I used
it.  Example:

  sndfile-play dq.wav

would work fine, but

  vsound sndfile-play dq.wav

would Bus error.

I have lost the output of the above command.  Running vsound on any
program that opened a file led to a Bus error, even if the program did
not use /dev/dsp.

After debugging to isolate the problem at vsound.c line 213 I finally
noticed that gcc had already found and solved the problem by giving
the following warning.

# cd /usr/ports/audio/vsound
# make
[...]
cc -DHAVE_CONFIG_H -I. -I. -I. -g -O -pipe -Wall -Wstrict-prototypes -pipe -c vsound.c  -fPIC -DPIC -o .libs/vsound.lo
vsound.c: In function `open':
vsound.c:213: warning: `mode_t' is promoted to `int' when passed through `...'
vsound.c:213: warning: (so you should pass `int' not `mode_t' to `va_arg')
vsound.c:213: note: if this code is reached, the program will abort
[...]

>Fix:
      
I have verified that the following patch fixes the problem on my
machine.  However, to the level I understand this problem, I don't see
how vsound would have worked for anyone on FreeBSD, so I'm suspicious
that the problem/fix is really this simple.  Perhaps something about
gcc or mode_t has changed to create this problem?

# diff -C4  vsound.c.bad vsound.c
*** vsound.c.bad        Mon Sep 19 15:06:43 2005
--- vsound.c    Mon Sep 19 15:07:09 2005
***************
*** 209,217 ****
  
        dsp_init () ;
  
        va_start (args, flags) ;
!       mode = va_arg (args, mode_t) ;
        va_end (args) ;
  
        if (strcmp (pathname, "/dev/dsp"))
        {       fd = func_open (pathname, flags, mode) ;
--- 209,217 ----
  
        dsp_init () ;
  
        va_start (args, flags) ;
!       mode = va_arg (args, int) ;
        va_end (args) ;
  
        if (strcmp (pathname, "/dev/dsp"))
        {       fd = func_open (pathname, flags, mode) ;

Building vsound from http://www.zorg.org/vsound/vsound-0.6.tar.gz has
the exact same proble/fix on my system.


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: pav 
State-Changed-When: Mon Oct 3 22:25:26 GMT 2005 
State-Changed-Why:  
Committed, thanks! 

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