Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Sep 2005 10:51:51 GMT
From:      Fred Wheeler <fred.s.wheeler@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/86365: port audio/vsound vsound.c fix to prevent abort
Message-ID:  <200509201051.j8KApp1g081464@www.freebsd.org>
Resent-Message-ID: <200509201100.j8KB0Osn014250@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 20 11:00:23 GMT 2005
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200509201051.j8KApp1g081464>