tap-plugins
tap-plugins copied to clipboard
TAP reflector goes into infinite loop when fragment length is set to 20 ms
Tested in Radium, Renoise, and QTractor.
Thread 18 (Thread 0x7fffd3fcc700 (LWP 16647)):
#0 0x00007fffea3658bf in read_buffer (buffer=0x7fffea10c800, buflen=5605, pos=3072, n=18446738455685574316) at tap_utils.h:61
#1 0x00007fffea366355 in run_Reflector (Instance=0x6100001afd40, SampleCount=64) at tap_reflector.c:251
#2 0x0000000000a84423 in RT_process (plugin=0x61500055e400, time=<optimized out>, num_frames=64, inputs=0x6020004b8e10, outputs=0x6020004b8df0) at audio/Ladspa_plugins.cpp:112
#3 0x0000000000a1482e in PLUGIN_RT_process (plugin=0x61500055e400, time=time@entry=714752, num_frames=num_frames@entry=64, inputs=<optimized out>, outputs=0x6020004b8df0, process_plugins=<optimized out>)
at audio/SoundProducer.cpp:493
#4 0x0000000000a1d41d in RT_process (process_plugins=true, num_frames=0, time=714752, this=0x6120009dd740) at audio/SoundProducer.cpp:1262
#5 SP_RT_process (producer=producer@entry=0x6120009dd740, time=time@entry=714752, num_frames=num_frames@entry=64, process_plugins=process_plugins@entry=true) at audio/SoundProducer.cpp:1400
#6 0x0000000000a1e317 in process_soundproducer (sp=sp@entry=0x6120009dd740, time=<optimized out>, num_frames=<optimized out>, process_plugins=true) at audio/MultiCore.cpp:64
#7 0x0000000000a22b42 in (anonymous namespace)::Runner::run (this=0x6070000fce90) at audio/MultiCore.cpp:143
#8 0x00007ffff37872a9 in ?? () from /home/kjetil/site_qt5/lib/libQt5Core.so.5
#9 0x0000003b49c07d14 in start_thread () from /lib64/libpthread.so.0
#10 0x0000003b494f168d in clone () from /lib64/libc.so.6
(gdb) thread 18
[Switching to thread 18 (Thread 0x7fffd3fcc700 (LWP 16647))]
#0 0x00007fffea3658bf in read_buffer (buffer=0x7fffea10c800, buflen=5605, pos=3072, n=18446738455685574316) at tap_utils.h:61
61 while (n + pos >= buflen)
(gdb) up
#1 0x00007fffea366355 in run_Reflector (Instance=0x6100001afd40, SampleCount=64) at tap_reflector.c:251
251 out_0 = read_buffer(ptr->ring0, ptr->buflen0, ptr->pos0,
(gdb) p *ptr
$1 = {fragment = 0x6030017b0060, drylevel = 0x6030017b0064, wetlevel = 0x6030017b0068, input = 0x611000c04940, output = 0x611000c046c0, ring0 = 0x7fffea10c800, buflen0 = 5605, pos0 = 3072,
ring1 = 0x7fffe9eb2800, buflen1 = 5605, pos1 = 3072, delay1 = 0x7fffe9c58800, delay_buflen1 = 1868, delay_pos1 = 0, ring2 = 0x7fffe9521800, buflen2 = 5605, pos2 = 3072, delay2 = 0x7fffe3824800,
delay_buflen2 = 3736, delay_pos2 = 0, fragment_pos = 14334, sample_rate = 48000, run_adding_gain = 1}
(gdb) p ptr->buflen0
$2 = 5605
(gdb) p ptr->fragment_pos
$3 = 14334
(gdb) p ptr->buflen1
$4 = 5605
(gdb) p fragment_pos1
$5 = 4992
(gdb) p fragment_pos2
$6 = 1255
(gdb) p ptr->buflen0 - ptr->fragment_pos - 1
$7 = 18446744073709542886
Here's a workaround:
--- kokkinizita/tap-plugins-0.7.3/tap_utils.h~ 2009-08-17 13:16:19.000000000 +0200
+++ kokkinizita/tap-plugins-0.7.3/tap_utils.h 2016-08-11 16:37:13.325499971 +0200
@@ -55,8 +55,8 @@
*/
static inline
LADSPA_Data
-read_buffer(LADSPA_Data * buffer, unsigned long buflen,
- unsigned long pos, unsigned long n) {
+read_buffer(LADSPA_Data * buffer, long buflen,
+ long pos, long n) {
while (n + pos >= buflen)
n -= buflen;
Maybe it's not only a workaround, but the proper fix too. I don't know. Personally, I never use unsigned types to avoid bugs like this.
Think some more workaround is needed:
diff --git a/kokkinizita/tap-plugins-git/tap_reverb.h b/kokkinizita/tap-plugins-git/tap_reverb.h
index 6dc8cb0..0e20a82 100644
--- a/kokkinizita/tap-plugins-git/tap_reverb.h
+++ b/kokkinizita/tap-plugins-git/tap_reverb.h
@@ -95,6 +95,9 @@ rev_t
read_buffer(rev_t * buffer, int buflen,
int pos, int n) {
+ while (n + pos < 0)
+ n += buflen;
+
while (n + pos >= buflen)
n -= buflen;
return buffer[n + pos];
@@ -112,6 +115,9 @@ void
write_buffer(rev_t insample, rev_t * buffer, int buflen,
int pos, int n) {
+ while (n + pos < 0)
+ n += buflen;
+
while (n + pos >= buflen)
n -= buflen;
buffer[n + pos] = insample;
diff --git a/kokkinizita/tap-plugins-git/tap_utils.h b/kokkinizita/tap-plugins-git/tap_utils.h
index 79bcf49..3a3e00f 100644
--- a/kokkinizita/tap-plugins-git/tap_utils.h
+++ b/kokkinizita/tap-plugins-git/tap_utils.h
@@ -56,9 +56,13 @@ LADSPA_Data
read_buffer(LADSPA_Data * buffer, int buflen,
int pos, int n) {
- while (n + pos >= buflen)
- n -= buflen;
- return buffer[n + pos];
+ while (n + pos < 0)
+ n += buflen;
+
+ while (n + pos >= buflen)
+ n -= buflen;
+
+ return buffer[n + pos];
}
@@ -73,6 +77,9 @@ void
write_buffer(LADSPA_Data insample, LADSPA_Data * buffer, int buflen,
int pos, int n) {
+ while (n + pos < 0)
+ n += buflen;
+