[LAU] Simple, easy multithreaded circular buffer library for Linux?

Ken Restivo ken at restivo.org
Sun Oct 19 15:44:41 EDT 2008


On Sun, Oct 19, 2008 at 09:23:44PM +0200, Olivier Guilyardi wrote:
> Ken Restivo a écrit :
>> On Sun, Oct 19, 2008 at 01:03:23PM +0200, Olivier Guilyardi wrote:
>>> Ken Restivo a écrit :
>>>> On Fri, Oct 17, 2008 at 04:39:25PM +0200, Olivier Guilyardi wrote:
>>>>> svn co http://svn.samalyse.com/misc/rbtest
>>>>> cd rbtest
>>>>> make test
>>>>>
>>>> cc -Wall -I. -I./jack -lpthread -o test-int-array-jack \
>>>> 		test-int-array.c jack/ringbuffer.c
>>>> test-int-array.c: In function ‘main’:
>>>> test-int-array.c:113: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
>>>> cc -Wall -I. -I./portaudio -lpthread -o test-int-array-portaudio \
>>>> 		test-int-array.c portaudio/ringbuffer.c portaudio/pa_ringbuffer.c
>>>> test-int-array.c: In function ‘main’:
>>>> test-int-array.c:113: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
>>>> cc -Wall -I. -I./portaudio -lpthread -o test-int-array-portaudio-nobarrier \
>>>> 		-DNO_MEMORY_BARRIER \
>>>> 		test-int-array.c portaudio/ringbuffer.c portaudio/pa_ringbuffer.c
>>>> test-int-array.c: In function ‘main’:
>>>> test-int-array.c:113: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
>>>> cc -Wall -I. -I./jack -lpthread -o test-int-array-jack-fix1 \
>>>> 		test-int-array.c jack/ringbuffer-fix1.c
>>>> test-int-array.c: In function ‘main’:
>>>> test-int-array.c:113: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
>>> I only got these warnings on Mac OS X, I suppose it depends on the gcc 
>>> and/or libc version. That did not cause any segfault in my case though. 
>>> I've fixed it anyway.
>>>
>>>> ./alltests.sh
>>>> Starting ringbuffer tests (buffer size: 512)
>>>>
>>>> === Jack ringbuffer test ===
>>>> starting ringbuffer stress test (2 minutes max)
>>>> buffer size (bytes): 512
>>>> array size (bytes): 256
>>>> ./alltests.sh: line 9:  7742 Segmentation fault      ./test-int-array-jack $BUFFER_SIZE
>>>>
>>>> Info on the system this was run on, is here:
>>>> http://restivo.nfshost.com/projects/asus/system-details/
>>> Please update rbtest to r309.
>>>
>>
>>
>> $ svn update
>> U    test-int-array.c
>> Updated to revision 309.
>>
>>
>> $ make clean
>> rm test-int-array-jack test-int-array-portaudio test-int-array-portaudio-nobarrier \
>> 		test-int-array-jack-fix1
>>
>>
>> $ make test
>> cc -Wall -I. -I./jack -lpthread -o test-int-array-jack \
>> 		test-int-array.c jack/ringbuffer.c
>> cc -Wall -I. -I./portaudio -lpthread -o test-int-array-portaudio \
>> 		test-int-array.c portaudio/ringbuffer.c portaudio/pa_ringbuffer.c
>> cc -Wall -I. -I./portaudio -lpthread -o test-int-array-portaudio-nobarrier \
>> 		-DNO_MEMORY_BARRIER \
>> 		test-int-array.c portaudio/ringbuffer.c portaudio/pa_ringbuffer.c
>> cc -Wall -I. -I./jack -lpthread -o test-int-array-jack-fix1 \
>> 		test-int-array.c jack/ringbuffer-fix1.c
>> ./alltests.sh
>> Starting ringbuffer tests (buffer size: 512)
>>
>> === Jack ringbuffer test ===
>> starting ringbuffer stress test (2 minutes max)
>> buffer size (bytes): 512
>> array size (bytes): 256
>> ./alltests.sh: line 9: 16706 Segmentation fault      ./test-int-array-jack $BUFFER_SIZE
>>
>> === Jack ringbuffer test (with fix 1) ===
>> starting ringbuffer stress test (2 minutes max)
>> buffer size (bytes): 512
>> array size (bytes): 256
>> ./alltests.sh: line 13: 16709 Segmentation fault      ./test-int-array-jack-fix1 $BUFFER_SIZE
>>
>> === Portaudio ringbuffer test ===
>> starting ringbuffer stress test (2 minutes max)
>> buffer size (bytes): 512
>> array size (bytes): 256
>> ./alltests.sh: line 17: 16712 Segmentation fault      ./test-int-array-portaudio $BUFFER_SIZE
>>
>> === Portaudio ringbuffer test (without memory barriers) ===
>> starting ringbuffer stress test (2 minutes max)
>> buffer size (bytes): 512
>> array size (bytes): 256
>> ./alltests.sh: line 21: 16715 Segmentation fault      ./test-int-array-portaudio-nobarrier $BUFFER_SIZE
>> make: *** [test] Error 139
>>
>> :-(
>>
>> $ dpkg -l libc6 gcc
>> ii  gcc                               4:4.1.2-3                       The GNU C compiler
>> ii  libc6                             2.7-1                           GNU C Library: Shared libraries
>>
>> Unfortunately, I cannot and will not update this machine right now to see if that makes rbtest work, because everything else on this machine works stably, it's my gigging synth as well as my laptop, and I can't afford to have it destablize. Sorry.
>
> That's weird. Please try this:
>
> cc -Wall -g -I. -I./jack -lpthread -o test-int-array-jack test-int-array.c 
> jack/ringbuffer.c
>
> gdb --args ./test-int-array-jack 512
>
> And type "run" in gdb

$ gdb --args ./test-int-array-jack 512                                                                                  
GNU gdb 6.6-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run
[Thread debugging using libthread_db enabled]
[New process 17156]
starting ringbuffer stress test (2 minutes max)
buffer size (bytes): 512
array size (bytes): 256
[New Thread 1082132816 (LWP 17164)]
[New Thread 47638797092576 (LWP 17156)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1082132816 (LWP 17164)]
0xffffffffff600808 in ?? ()

(gdb) bt
#0  0xffffffffff600808 in ?? ()
#1  0x00002b53c56aa7f0 in sched_getcpu () from /lib/libc.so.6
#2  0x0000000000400941 in reader_start (arg=0x0) at test-int-array.c:50
#3  0x00002b53c53cd3f7 in start_thread () from /lib/libpthread.so.0
#4  0x00002b53c56b993d in clone () from /lib/libc.so.6

(gdb) f 1
#1  0x00002b53c56aa7f0 in sched_getcpu () from /lib/libc.so.6

(gdb) f 2
#2  0x0000000000400941 in reader_start (arg=0x0) at test-int-array.c:50
50	  printf("reader started on cpu %d\n", sched_getcpu());


(gdb) i thr
  4 Thread 1090525520 (LWP 17165)  0x00002b53c56b9901 in clone () from /lib/libc.so.6
  3 Thread 47638797092576 (LWP 17156)  0x00002b53c56b9901 in clone () from /lib/libc.so.6
* 2 Thread 1082132816 (LWP 17164)  0xffffffffff600808 in ?? ()
  1 LWP 17156  0x00002b53c56b9901 in clone () from /lib/libc.so.6


Weird, indeed.

-ken



More information about the Linux-audio-user mailing list