Re: [linux-audio-dev] strange jack ringbuffer problem

From: Magnus Hjorth <magnus.hjorth@email-addr-hidden>
Date: Fri Feb 18 2005 - 10:17:04 EET

Hi Hans!

I took a quick look at your code.

Shouldn't
            src_float_to_short_array(bp, (short*)(vec[i].buf),
                    len*sizeof(short));
instead be
            src_float_to_short_array(bp, (short*)(vec[i].buf), len);
??

Regards,
Magnus

On Thu, 17 Feb 2005 22:58:03 -0700
Hans Fugal <hans@email-addr-hidden> wrote:

> I've been banging my head against this one all evening. Now I'm going to
> go to sleep on it, but I throw it out for the wiser and more experienced
> to see if you can see my error.
>
> The code is at http://fugal.net/~fugalh/src/alex which you are welcome
> to refer to and critique.
>
> It segfaults on line 171 of jack.cc, but not if I comment out line 158
> (or use 0 for the second argument). It seems to segfault once input_rb
> is nearly or completely to the end (not full, since it is being drained
> by the other thread; it's just as it would wrap around). The autopsy
> shows that it is segfaulting because output_rb and consequentially vec
> is completely hosed. What I don't understand is how
> jack_ringbuffer_write_advance(input_rb, something_plenty_small) could
> possibly hose output_rb. something_plenty_small is usually on the order
> of 160 bytes. I'm running jackd with a 512 byte buffer at 48000Hz.
>
> (gdb) bt
> #0 0xb7f91253 in src_short_to_float_array () from /usr/lib/libsamplerate.so.0
> #1 0x0804a01c in Jack::jack_process (this=0xbffff300, nframes=512,
> arg=0xbffff300) at jack.cc:171
> #2 0x08049d87 in Jack::jack_process_wrapper (nframes=512, arg=0xbffff300)
> at jack.cc:114
> #3 0xb7fb255d in jack_stop_freewheel () from /usr/lib/libjack-0.80.0.so.0
> #4 0xb7d639b4 in start_thread () from /lib/tls/libpthread.so.0
> #5 0x00000000 in ?? ()
> (gdb) up
> #1 0x0804a01c in Jack::jack_process (this=0xbffff300, nframes=512,
> arg=0xbffff300) at jack.cc:171
> 171 src_short_to_float_array((short*)vec[i].buf, buf, vframes);
> (gdb) p *output_rb
> $1 = {buf = 0xd0b0c860 <Address 0xd0b0c860 out of bounds>,
> write_ptr = 92858992, read_ptr = 88669736, size = 4291362712,
> size_mask = 13171512, mlocked = 3735008}
> (gdb) p vec
> $2 = {{buf = 0xd5f9c688 <Address 0xd5f9c688 out of bounds>, len = 4189256}, {
> buf = 0x804d028 "����", len = 0}}
> (gdb) p *input_rb
> $3 = {buf = 0x804d028 "����", write_ptr = 16266, read_ptr = 16266,
> size = 16384, size_mask = 16383, mlocked = 0}
>
> I hope someone can see what I'm doing wrong.
>
> Consider the code under the GPL.
>
> --
> .O. Hans Fugal | De gustibus non disputandum est.
> ..O http://hans.fugal.net | Debian, vim, mutt, ruby, text, gpg
> OOO | WindowMaker, gaim, UTF-8, RISC, JS Bach
> ---------------------------------------------------------------------
> GnuPG Fingerprint: 6940 87C5 6610 567F 1E95 CB5E FC98 E8CD E0AA D460
>
>
Received on Fri Feb 18 12:15:11 2005

This archive was generated by hypermail 2.1.8 : Fri Feb 18 2005 - 12:15:11 EET