tim-janik / beast

Beast - Music Synthesizer and Composer
GNU Lesser General Public License v2.1
84 stars 12 forks source link

Crashes in Resampler #138

Closed tim-janik closed 2 years ago

tim-janik commented 4 years ago

Compiling beast as follows crashes the resampler.

# disable ASAN spam to stderr about leaks
export ASAN_OPTIONS=detect_leaks=0
# build with address sanitizer
make default MODE=asan
make clean
make -j11
make check

Note that there's a mismatch in order indexing and allocation in bseresampler.cc in several places:

# 418
fir_compute_sse_taps (const vector<float>& taps)
{
  const int order = taps.size();
  vector<float> sse_taps ((order + 6) / 4 * 16);
# 470
     AlignedArray<float,16> random_mem (order + 4);
      for (uint i = 0; i < order + 4; i++)
        random_mem[i] = 1.0 - rand() / (0.5 * RAND_MAX);
# 362
fir_process_4samples_sse (const float *input,
// ...
  for (uint i = 1; i < (order + 6) / 4; i++)
  {
    out0_v.v=_mm_add_ps(out0_v.v, _mm_mul_ps(input_v[i].v, sse_taps_v[i*4+0].v));

In the above snippet, input_v == random_mem. It is allocated as order+4 and indexed as order+6.

tim-janik commented 2 years ago

Beast development is continued in Anklang, this should be fixed there.