NetBSD Problem Report #41171
From root@test3.netherworld.org Wed Apr 8 08:04:16 2009
Return-Path: <root@test3.netherworld.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id A84CA63BC38
for <gnats-bugs@gnats.NetBSD.org>; Wed, 8 Apr 2009 08:04:16 +0000 (UTC)
Message-Id: <20090408064553.71E3DFC3F@test3.netherworld.org>
Date: Wed, 8 Apr 2009 02:45:53 -0400 (EDT)
From: mag@netherworld.org
Reply-To: mag@netherworld.org
To: gnats-bugs@gnats.NetBSD.org
Subject: audio/timidity Sun audio bug
X-Send-Pr-Version: 3.95
>Number: 41171
>Category: pkg
>Synopsis: mismatched calling convention with Sun audio device
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: pkg-manager
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Apr 08 08:05:00 +0000 2009
>Closed-Date: Fri Apr 10 18:45:36 +0000 2009
>Last-Modified: Fri Apr 10 18:50:02 +0000 2009
>Originator: John E. Krokes
>Release: NetBSD 5.0_RC3 200903200521Z
>Organization:
>Environment:
System: NetBSD test3.netherworld.org 5.0_RC3 NetBSD 5.0_RC3 (GENERIC.MP) #0: Fri Mar 20 18:16:50 UTC 2009 builds@b4.netbsd.org:/home/builds/ab/netbsd-5-0-RC3/sparc64/200903200521Z-obj/home/builds/ab/netbsd-5-0-RC3/src/sys/arch/sparc64/compile/GENERIC.MP sparc64
Architecture: sparc64
Machine: sparc64
>Description:
In timidity/aq.c, in aq_setup(), there is a function call to acntl().
if(play_mode->acntl(PM_REQ_GETFRAGSIZ, &bucket_size) == -1)
bucket_size = audio_buffer_size * Bps;
bucket_time = (double)bucket_size / Bps / play_mode->rate;
As I read this, it says:
Call acntl, passing in a constant and a variable by reference.
If acntl() returns -1 (for failure),
set bucket_size to a default value,
else
ignore the return value and do not set bucket_size.
Perform a calculation based on the value of bucket_size.
So, one presumes that acntl() is supposed to modify bucket_size in
place if it succeeds.
When using a Sun audio device, the relevant code is in
timidity/sun_a.c, in acntl().
case PM_REQ_GETFRAGSIZ:
if(ioctl(audioctl_fd, AUDIO_GETINFO, &auinfo) < 0)
return -1;
return auinfo.blocksize;
Clearly, if the ioctl() succeeds, it will return a value to the
caller instead of modifying a variable.
Thus, bucket_size is not set to a meaningful value but is
instead used uninitialized in subsequent calculations.
Further on in the code, this leads to division-by-zero, and eventually
timidity exits after printing this error message:
Strange, I feel like allocating -24 bytes. This must be a bug.
>How-To-Repeat:
timidity -id -Od anyfile.mid
>Fix:
workaround:
timidity -id -Ou -o anyfile.au anyfile.mid
cat anyfile.au > /dev/audio
Or, apply this patch:
-----cut-here-----
*** timidity/sun_a.c.orig Tue Apr 7 17:04:26 2009
--- timidity/sun_a.c Tue Apr 7 17:05:53 2009
***************
*** 345,356 ****
case PM_REQ_GETQSIZ:
if(ioctl(audioctl_fd, AUDIO_GETINFO, &auinfo) < 0)
return -1;
! return auinfo.play.buffer_size;
case PM_REQ_GETFRAGSIZ:
if(ioctl(audioctl_fd, AUDIO_GETINFO, &auinfo) < 0)
return -1;
! return auinfo.blocksize;
case PM_REQ_OUTPUT_FINISH:
return ioctl(audioctl_fd, AUDIO_DRAIN, NULL);
--- 345,358 ----
case PM_REQ_GETQSIZ:
if(ioctl(audioctl_fd, AUDIO_GETINFO, &auinfo) < 0)
return -1;
! *((int *)arg) = auinfo.play.buffer_size;
! return 0;
case PM_REQ_GETFRAGSIZ:
if(ioctl(audioctl_fd, AUDIO_GETINFO, &auinfo) < 0)
return -1;
! *((int *)arg) = auinfo.blocksize;
! return 0;
case PM_REQ_OUTPUT_FINISH:
return ioctl(audioctl_fd, AUDIO_DRAIN, NULL);
-----cut-here-----
This patch modifies code added by patch-aa in pkgsrc-2008Q4. Perhaps
it would be smarter to modify the patch rather than patch the same
code twice.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Fri, 10 Apr 2009 18:45:36 +0000
State-Changed-Why:
Fixed, thank you very much!
From: Thomas Klausner <wiz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/41171 CVS commit: pkgsrc/audio/timidity
Date: Fri, 10 Apr 2009 18:45:16 +0000
Module Name: pkgsrc
Committed By: wiz
Date: Fri Apr 10 18:45:16 UTC 2009
Modified Files:
pkgsrc/audio/timidity: Makefile distinfo
pkgsrc/audio/timidity/patches: patch-aa patch-ab
Log Message:
Fix acnlt() return value handling for NetBSD sound device.
From John E. Krokes in PR 41171.
Bump PKGREVISION.
To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 pkgsrc/audio/timidity/Makefile
cvs rdiff -u -r1.13 -r1.14 pkgsrc/audio/timidity/distinfo
cvs rdiff -u -r1.7 -r1.8 pkgsrc/audio/timidity/patches/patch-aa
cvs rdiff -u -r1.13 -r1.14 pkgsrc/audio/timidity/patches/patch-ab
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.