encoding crashes on SunOS due to improper use of `qsort'
I just tracked down and fixed a bug on SunOS where each and every attempt to
oggencode a wave-file crashed. Backtrace shows the crash to occur at
psy.c:_vp_noise_normalize_sort,
at the call to `qsort', within the callback `apsort'.
qsort was called with following args:
qsort ((float **) 0xffbfefb8, 8, 4, apsort)
apsort was called with following args:
apsort (a=0xffbfefb4, b=0xffbfefbc)
As one can see 0xffbf4fb4<0xffbfefb8, a array underrun occured. A description
of what seems to be the same problem dates back to 1999:
http://www.geocrawler.com/mail/msg.php3?msg_id=1607386&list=117.
The problem seems to be the "misuse" of qsort, validating the specification:
`apsort' returns `-1' even for equal values. A patch that makes it return `0'
for equals fixes the problem. Patch at:
http://user.cs.tu-berlin.de/~dvdkhlng/bugfix-qsort-20031103.diff
Some more info:
uname -a
SunOS siesta 5.9 Generic_112233-08 sun4u sparc SUNW,Ultra-4
gcc --version
gcc (GCC) 3.3.1
~/bin/oggenc --version
OggEnc v1.0 (libvorbis 1.0)
Oggenc also crashed when I tried to run it about half a year ago on an earlier
version of SunOS, here at my university. I didn't do any debugging back then.
Could it be, that this bug affects libvorbis on *all* SunOS installations?
David Kuehling