LMMS / lmms

Cross-platform music production software
https://lmms.io
GNU General Public License v2.0
7.98k stars 994 forks source link

LADSPA Caps Amp effect crash when FPE debugging enabled #5882

Open Veratil opened 3 years ago

Veratil commented 3 years ago

Bug Summary

When loading any demo projects containing the LADSPA CAPS Amp effect, LMMS crashes.

Steps to reproduce

  1. Build master with FPE debugging enabled
  2. Run LMMS
  3. Load a demo project (for example demos/CapDan/CapDan-TwilightArea-OriginalByAlf42red.mmpz)

Expected behavior

LMMS loads the demo project

Actual behavior

LMMS crashes during load of demo project

Affected LMMS versions

LMMS 1.3.0-alpha.1.65+g623e35ca2 Unknown how further back this crash affects.

Logs

@PhysSong and myself start searching for clues starting here: discord message of gdb backtrace I tracked it back to this line. Following that @PhysSong tracked down an update fixing the function in CAPS 0.9.25.

Small backport of the function and I can load demos successfully.

diff --git a/plugins/LadspaEffect/caps/dsp/windows.h b/plugins/LadspaEffect/caps/dsp/windows.h
index 949a95818..44a4cd734 100644
--- a/plugins/LadspaEffect/caps/dsp/windows.h
+++ b/plugins/LadspaEffect/caps/dsp/windows.h
@@ -142,13 +142,14 @@ kaiser (sample_t * s, int n, double beta)
        double bb = besseli (beta);
        int si = 0;

-       for (double i = -n / 2 + .1; si < n; ++si, ++i)
+       for (double i = -n / 2. + .5; si < n; ++si, ++i)
        {
-               double k = besseli ((beta * sqrt (1 - pow ((2 * i / (n - 1)), 2)))) / bb;
+               double a = 1 - pow((2 * i / (n - 1)), 2);
+               double k = besseli ((beta * (a < 0 ? 0 : sqrt(a)))) / bb;

                /* can you spell hack */
-               if (!isfinite (k) || isnan(k))
-                       k = 0;
+               /*if (!isfinite (k) || isnan(k))
+                       k = 0;*/

                F (s[si], k);
        }
CLandel89 commented 2 years ago

Enabling FPE debugging (-DWANT_DEBUG_FPE=true) causes A LOT of trouble. I'm on a current KUbuntu 22.04, and current master yields this console output when I compile it with FPE debugging and try to add a Monstro or Sample as a track:

``` user@christian:~$ /opt/lmms-220704-9705/bin/lmms *** WEAK-JACK: initializing *** WEAK-JACK: OK. (0) Notice: could not set realtime priority. Failed to allocate shared memory for VST sync: SharedMemoryImpl: shm_open() failed: Die Datei existiert bereits Lv2 plugin SUMMARY: 11 of 29 loaded in 12 msecs. For details about not loaded plugins, please set environment variable "LMMS_LV2_DEBUG" to nonempty. Connection established. Die Bibliothek /opt/lmms-220704-9705/lib/lmms/libcarlabase.so kann nicht geladen werden: (libcarla_native-plugin.so: Kann die Shared-Object-Datei nicht öffnen: Datei oder Verzeichnis nicht gefunden) Die Bibliothek /opt/lmms-220704-9705/lib/lmms/libcarlarack.so kann nicht geladen werden: (libcarlabase.so: Kann die Shared-Object-Datei nicht öffnen: Datei oder Verzeichnis nicht gefunden) Die Bibliothek /opt/lmms-220704-9705/lib/lmms/libcarlapatchbay.so kann nicht geladen werden: (libcarlabase.so: Kann die Shared-Object-Datei nicht öffnen: Datei oder Verzeichnis nicht gefunden) Stream successfully created /opt/lmms-220704-9705/bin/lmms(_Z13signalHandleri+0x2f)[0x56286ad78958] /lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7fb9ef4a5520] /lib/x86_64-linux-gnu/libQt5Gui.so.5(_ZN10QBasicDrag9startDragEv+0x35)[0x7fb9f00a1215] /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5(+0x88eca)[0x7fb9eb6ebeca] /lib/x86_64-linux-gnu/libQt5Gui.so.5(_ZN10QBasicDrag4dragEP5QDrag+0x22)[0x7fb9f009ff92] /lib/x86_64-linux-gnu/libQt5Gui.so.5(_ZN12QDragManager4dragEP5QDrag+0x129)[0x7fb9f009d3e9] /lib/x86_64-linux-gnu/libQt5Gui.so.5(_ZN5QDrag4execE6QFlagsIN2Qt10DropActionEES2_+0x7f)[0x7fb9f009d73f] /opt/lmms-220704-9705/bin/lmms(_ZN4lmms3gui14StringPairDragC2ERK7QStringS4_RK7QPixmapP7QWidget+0x272)[0x56286af169d2] /opt/lmms-220704-9705/bin/lmms(_ZN4lmms3gui16PluginDescWidget15mousePressEventEP11QMouseEvent+0xbc)[0x56286af09594] /lib/x86_64-linux-gnu/libQt5Widgets.so.5(_ZN7QWidget5eventEP6QEvent+0x20e)[0x7fb9f10d44ee] lmms: /home/user/lmms-git/src/3rdparty/rpmalloc/rpmalloc/rpmalloc/rpmalloc.c:1328: _rpmalloc_span_finalize: Zusicherung »(span->list_size == span->used_count) && "Memory leak detected"« nicht erfüllt. Abgebrochen (Speicherabzug geschrieben) ```
zonkmachine commented 5 months ago

Enabling FPE debugging (-DWANT_DEBUG_FPE=true) causes A LOT of trouble.

As it's supposed to. It's for hard core troubleshooting. We test for issues that the user wouldn't have noticed if we fixed or not. You would not have this option enabled on a daily basis.

zonkmachine commented 5 months ago

Following that @PhysSong tracked down an update fixing the function in CAPS 0.9.25.

I can confirm the fix. @Veratil I suggest you merge the patch above as a temporary fix until the caps submodule is done.

Edit: The update message in CAPS 0.9.25 is somewhat intriguing.


0.9.25
  * potential gcc overoptimisation resulting in NaN in Kaiser window setup eliminated
    (fix contributed by Jean Pierre Cimalando)