brummer10 / Fluida.lv2

Fluidsynth as LV2 plugin
GNU General Public License v2.0
33 stars 4 forks source link

Segmentation fault (core dumped) #11

Closed KeithSBB closed 2 years ago

KeithSBB commented 2 years ago

Current version will not run as a Reaper plugin. Immediately crashes with no log messages. System: Fedora Jam 35 Fluida.lv2-0.7 built Jan 30, 2022

from dmesg:

reaper[23868]: segfault at 10 ip 00007fb310b9ea85 sp 00007ffeb18962c0 error 6 in Fluida_ui.so[7fb310b99000+37000]
[18383.602885] Code: 00 00 00 00 e8 fc a5 ff ff 48 89 c7 e8 f4 ac ff ff 48 8b bd f0 00 00 00 48 89 83 70 01 00 00 48 8b 9b f8 00 00 00 48 8b 73 18 <48> 89 46 10 48 83 c4 38 5b 5d 41 5c 41 5d 41 5e 41 5f e9 b0 63 00
[18749.538559] reaper[24706]: segfault at 10 ip 00007fd81e845a85 sp 00007ffed9cea090 error 6 in Fluida_ui.so[7fd81e840000+37000]
[18749.538565] Code: 00 00 00 00 e8 fc a5 ff ff 48 89 c7 e8 f4 ac ff ff 48 8b bd f0 00 00 00 48 89 83 70 01 00 00 48 8b 9b f8 00 00 00 48 8b 73 18 <48> 89 46 10 48 83 c4 38 5b 5d 41 5c 41 5d 41 5e 41 5f e9 b0 63 00
[18864.515449] reaper[24954]: segfault at 10 ip 00007f7f6cf43a85 sp 00007ffc4501f2d0 error 6 in Fluida_ui.so[7f7f6cf3e000+37000]
[18864.515458] Code: 00 00 00 00 e8 fc a5 ff ff 48 89 c7 e8 f4 ac ff ff 48 8b bd f0 00 00 00 48 89 83 70 01 00 00 48 8b 9b f8 00 00 00 48 8b 73 18 <48> 89 46 10 48 83 c4 38 5b 5d 41 5c 41 5d 41 5e 41 5f e9 b0 63 00
brummer10 commented 2 years ago

Strange. Still I don't know much about Reaper, but you may try to use lv2vst https://github.com/x42/lv2vst to wrap fluida as vst plugin. When that works, the issue may be in the Reaper LV2 implementation. As Fluida works fine in Ardour/Carla/Qtractor/ . . .

KeithSBB commented 2 years ago

Under Fedora 34 with Reaper Fluida-lv2 worked fine. I really miss not having it. I'll try the link you posted and report back. Other lv2 plugins seem to work fine under Reaper

brummer10 commented 2 years ago

So have you re-build Fluida after update to Fedora 35? Also you should give the development version from git a try.

KeithSBB commented 2 years ago

Yes, I built Fluida under Fedora 35. I just tested it with Ardour 6.9.0 and it crashed with this dmesg:

 ArdourGUI[5029]: segfault at 10 ip 00007f2e94031ebe sp 00007ffd228d49e0 error 6 in Fluida_ui.so[7f2e94030000+37000]
[ 2310.670502] Code: 49 b8 10 00 00 00 00 04 00 00 48 8b 4a 18 48 c1 e6 20 4c 89 4c 24 08 48 c1 e7 20 48 83 ce 08 4d 8b be 68 01 00 00 48 83 cf 01 <48> 89 41 10 4d 89 26 4d 89 46 08 49 89 b6 88 01 00 00 41 8b b6 f0

Seems to be related to selection of the soundfont file (fluidsynth default .sf2 which all works fine under qsynth). After I select it from the popup file dialog in Fluida is when it crashes. In Reaper this happen the first time, but ever since it crashes when I try to access the Fluida GUI. Any debug suggestions?

brummer10 commented 2 years ago

Do you use the development version, or the last release? Please use the development version.

KeithSBB commented 2 years ago

OK, I did a freah download of libxputty and Fluida from 'Master", built it and tested on Reaper and I get the same error:

reaper[8707]: segfault at 10 ip 00007f23c0ca9a85 sp 00007fff55633e60 error 6 in Fluida_ui.so[7f23c0ca4000+37000]
[ 3597.051774] Code: 00 00 00 00 e8 fc a5 ff ff 48 89 c7 e8 f4 ac ff ff 48 8b bd f0 00 00 00 48 89 83 70 01 00 00 48 8b 9b f8 00 00 00 48 8b 73 18 <48> 89 46 10 48 83 c4 38 5b 5d 41 5c 41 5d 41 5e 41 5f e9 b0 63 00

I'm using cairo-devel-1.17.4-4.fc35.x86_64

brummer10 commented 2 years ago

Seems to be related to selection of the soundfont file (fluidsynth default .sf2 which all works fine under qsynth). After I select it from the popup file dialog in Fluida is when it crashes.

What happen when you try to load a sf2 by drag and drop?

KeithSBB commented 2 years ago

With Reaper the Fluida GUI crashes when I try to open it, so I can't get to drag-n-drop. With Ardour, I can drag the file over the GUI and its green (OK to drop), but nothing happens when I drop it.

brummer10 commented 2 years ago

So I've downloaded reaper to check this out. 2022-02-05_07-11

I can't reproduce the issue. So it must be related to some system library. Which version of fluidsynth is comming with fedora 35? I also checked drag and drop, didn't work in reaper, but works fine in ardour here. I'm using debian/sid.

brummer10 commented 2 years ago

With Reaper the Fluida GUI crashes when I try to open it, so I can't get to drag-n-drop. With Ardour, I can drag the file over the GUI and its green (OK to drop), but nothing happens when I drop it.

Maybe you use wayland?

KeithSBB commented 2 years ago

Fedora Jam 35 is the Red Hat ecosystem's version of Ubuntu studio. It uses KDE Plasma and Wayland by default, but allows switching to X11. I logged in using X11 and I get the same failures. For the Fluida build I used fluidsynth-devel-2.2.4-1.fc35.x86_64 and Fedora Jam 35 comes with FluidSynth 2.2.4

I can't drag-n-drop under Ardour when using X11 (Wayland was difficult but I pulled it off once) because the Fluida GUI disappears when I change focus to the File Browser to select and drag the soundfont file.

Seems like better debugging of the problem is needed. Is there anything I can do?

Thanks,

brummer10 commented 2 years ago

Debugging LV2 plugs is a bit difficult. First of the host needs to be build with debugging symbols, there the Ardour debugging version from https://nightly.ardour.org/ is useful. Also the plug needs to be build with debugging symbols. Unfortunately I ain't have implement a debug build for Fluida in the makefile. So to make a debug build you need to edit the /Fluida/Makefile line 41 an add -g to the CXXFLAGS. Then run make clean && make debug && make. make debug will fail, but build libxputty with debugging symbols, after that run make again will build fluida and use the lib with the debugging enabled. After insatll it you could run ardour with the --gdb commandline switch. (Use the jack dummy driver for that, never do that with the normal jack realtime driver). At least, that may give us a more usable backtrace and maybe we find out what the culprit is. You may first try jalv to run Fluida to check if it works there for you.

KeithSBB commented 2 years ago

OK, I'm not sure about Jack as Fedora Jam uses pipewire and wireplumber. I'll look into it and report back if I get any success

KeithSBB commented 2 years ago

I did a partial debug. I put some fprintf statements to try to isolate where the fault is occurring. The soundfont looks like its getting loaded and nothing bad happens until after LV2_WorkerStatus Fluida::work is called. At the end of this function I'm printing out "LV2_WORKER_SUCCESS" (see below). It may be associated with putting the soundfont file path text into the GUI. Here's the debug output from Reaper (although I don't have debug versions yet):

$ reaper
jack: created client
jack: setting TIME_CRITICAL = 81
jack: activated client

{Here I add Fluida to my Reaper project and it  automatically loads the default.sf2 soundfont).
the following is output from Fluida debug }

assert(w)
XCreateWindow
Childlist_t  add_child
size of Func_t = 20
assert(w)
XCreateWindow
LV2_WORKER_SUCCESS   {This is the print statement I added assuring that the soundfont was loaded}
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
size of Func_t = 20
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
Childlist_t  add_child
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
Widget_t add adjustment
Widget_t set adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
Widget_t set adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
Widget_t set adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
Widget_t set adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
Widget_t set adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
Widget_t set adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
Widget_t set adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
Widget_t set adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
Widget_t set adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
assert(w)
XCreateWindow
Childlist_t  add_child
size of Func_t = 20
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
Childlist_t  add_child
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
Widget_t add adjustment
Widget_t set adjustment
Widget_t set adjustment
Adjustment_t check_value_changed 0.000000
Widget_t _transparency 
Widget_t _dummy callback
assert(w)
XCreateWindow
Childlist_t  add_child
Childlist_t  add_child
size of Widget_t = 448
Widget_t add adjustment
Widget_t set adjustment
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _dummy callback
Widget_t _transparency 
Widget_t Expose 
Segmentation fault (core dumped)
brummer10 commented 2 years ago

Widget_t Expose Segmentation fault (core dumped)

So we know now that it segfault after it first try to draw the UI. At this point we need the back trace from the debugger (gdb) to indicate the exact call which lead to the segfault. Maybe then I could implement a protection against that.

KeithSBB commented 2 years ago

I've never used gdb before and I don't seem to be getting the debug information for Fluida. I built it with the -g switch. I downloaded debug info for the version of Ardour I have. Here's the segfault and the stack trace, but no info for Fluida_ui.so.

I'm running: ardour6 --gdb which starts the debugger and ardour then 'r'

Do you know what I'm doing wrong? Thanks

Thread 1 "ArdourGUI" received signal SIGSEGV, Segmentation fault.
0x00007fff4c02eede in ?? () from /home/Keith/.lv2/Fluida.lv2/Fluida_ui.so
(gdb) bt
#0  0x00007fff4c02eede in  () at /home/Keith/.lv2/Fluida.lv2/Fluida_ui.so
#1  0x00007fff4c048361 in  () at /home/Keith/.lv2/Fluida.lv2/Fluida_ui.so
#2  0x00007fff4c0463f9 in  () at /home/Keith/.lv2/Fluida.lv2/Fluida_ui.so
#3  0x00007fff4c0346b7 in  () at /home/Keith/.lv2/Fluida.lv2/Fluida_ui.so
#4  0x00007fff4c03376a in  () at /home/Keith/.lv2/Fluida.lv2/Fluida_ui.so
#5  0x00007fff4c03f617 in  () at /home/Keith/.lv2/Fluida.lv2/Fluida_ui.so
#6  0x00007fff4c0395e2 in  () at /home/Keith/.lv2/Fluida.lv2/Fluida_ui.so
#7  0x00007fff4c036c89 in  () at /home/Keith/.lv2/Fluida.lv2/Fluida_ui.so
#8  0x00007fff4c0305ad in  () at /home/Keith/.lv2/Fluida.lv2/Fluida_ui.so
#9  0x00007fffc4d42a8c in suil_x11_wrapper_idle (data=data@entry=0x55555c88e800) at ../src/x11_in_gtk2.c:457
#10 0x00007ffff6e908b1 in g_timeout_dispatch (source=0x55555d7eb7f0, callback=0x7fffc4d42a60 <suil_x11_wrapper_idle>, user_data=0x55555c88e800)
    at ../glib/gmain.c:4933
#11 0x00007ffff6e9005f in g_main_dispatch (context=0x555556bc0fc0) at ../glib/gmain.c:3381
#12 g_main_context_dispatch (context=0x555556bc0fc0) at ../glib/gmain.c:4099
#13 0x00007ffff6ee52a8 in g_main_context_iterate.constprop.0 (context=0x555556bc0fc0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>)
    at ../glib/gmain.c:4175
#14 0x00007ffff6e8f773 in g_main_loop_run (loop=0x5555569a0ed0) at ../glib/gmain.c:4373
#15 0x00007ffff6ac3152 in IA__gtk_main () at /usr/src/debug/gtk2-2.24.33-5.fc35.x86_64/gtk/gtkmain.c:1270
#16 0x00007ffff72c76ca in Gtkmm2ext::UI::run(Receiver&) (this=0x555556bd1440, old_receiver=...) at ../libs/gtkmm2ext/gtk_ui.cc:310
#17 0x0000555555954162 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at ../gtk2_ardour/main.cc:422
KeithSBB commented 2 years ago

OK, there's no debug symbols in Fluida_ui.so. I'll try to figure out why the -g option isn't working...

KeithSBB commented 2 years ago

Found it, the strip commands in the makefile were removing the debug info. I commented them out, Here's the stack trace:

hread 1 "ArdourGUI" received signal SIGSEGV, Segmentation fault.
0x00007fff3005fede in synth_load_response (w_=<optimized out>, user_data=0x55555cb79270) at fluida_ui.c:134
134             filebutton->path = ps->dir_name;
(gdb) bt
#0  0x00007fff3005fede in synth_load_response (w_=<optimized out>, user_data=0x55555cb79270) at fluida_ui.c:134
#1  0x00007fff30079361 in fdialog_response (w_=0x55555cacff90, user_data=0x55555cb79270) at ../xputty/dialogs/xfile-dialog.c:722
#2  0x00007fff300773f9 in button_ok_callback (w_=0x55555df48c20, user_data=0x7fffffffd204) at ../xputty/dialogs/xfile-dialog.c:298
#3  0x00007fff300656b7 in check_value_changed (adj=0x55555e3d1320, value=0x7fffffffd204) at ../xputty/xadjustment.c:268
#4  0x00007fff3006476a in adj_set_value (adj=0x55555e3d1320, v=0) at ../xputty/xadjustment.c:170
#5  0x00007fff30070617 in _button_released (w_=0x55555df48c20, button_=0x7fffffffd300, user_data=0x0) at ../xputty/widgets/xbutton_private.c:399
#6  0x00007fff3006a5e2 in widget_event_loop (w_=0x55555df48c20, event=0x7fffffffd300, main=0x55555c8abaa8, user_data=0x0) at ../xputty/xwidget.c:585
#7  0x00007fff30067c89 in run_embedded (main=0x55555c8abaa8) at ../xputty/xputty.c:161
#8  0x00007fff300615ad in ui_idle (handle=0x55555c8abaa0) at /home/Keith/Fluida/Fluida.lv2-master/Fluida/lv2_plugin.cc:183
#9  0x00007fffc0d42a8c in suil_x11_wrapper_idle (data=data@entry=0x55555c6b3800) at ../src/x11_in_gtk2.c:457
#10 0x00007ffff6e908b1 in g_timeout_dispatch (source=0x55555cfeaa10, callback=0x7fffc0d42a60 <suil_x11_wrapper_idle>, user_data=0x55555c6b3800)
    at ../glib/gmain.c:4933
#11 0x00007ffff6e9005f in g_main_dispatch (context=0x555556bc29e0) at ../glib/gmain.c:3381
#12 g_main_context_dispatch (context=0x555556bc29e0) at ../glib/gmain.c:4099
#13 0x00007ffff6ee52a8 in g_main_context_iterate.constprop.0 (context=0x555556bc29e0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>)
    at ../glib/gmain.c:4175
#14 0x00007ffff6e8f773 in g_main_loop_run (loop=0x555556cce480) at ../glib/gmain.c:4373
#15 0x00007ffff6ac3152 in IA__gtk_main () at /usr/src/debug/gtk2-2.24.33-5.fc35.x86_64/gtk/gtkmain.c:1270
#16 0x00007ffff72c76ca in Gtkmm2ext::UI::run(Receiver&) (this=0x555556bd2fd0, old_receiver=...) at ../libs/gtkmm2ext/gtk_ui.cc:310
#17 0x0000555555954162 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at ../gtk2_ardour/main.cc:422
KeithSBB commented 2 years ago

and here's the problem: No parent_struct for ps->dia

(gdb) p ps->dir_name
$1 = 0x5555568a1fa0 "/usr/share/soundfonts"
(gdb) p filebutton->path
Cannot access memory at address 0x10
(gdb) p ps->dia->parent_struct
$2 = (void *) 0x0
(gdb) p ps->dia
$3 = (Widget_t *) 0x55555cacff90
KeithSBB commented 2 years ago

In Reaper the segfault takes place here:

Widget_t Expose 
/usr/share/soundfonts/default.sf2

Thread 1 "reaper" received signal SIGSEGV, Segmentation fault.
0x00007fffe8834a95 in plugin_port_event (handle=0xf066000, port_index=<optimized out>, buffer_size=<optimized out>, format=<optimized out>, buffer=<optimized out>) at fluida_ui.c:457
457                                 filebutton->path = ps->dir_name;
Missing separate debuginfos, use: dnf debuginfo-install ffmpeg-libs-4.4.1-4.fc35.x86_64 libcurl-gnutls-7.79.1-1.fc35.x86_64 librtmp-2.4-20.20190330.gitc5f04a5.fc35.x86_64 opencore-amr-0.1.5-13.fc35.x86_64 vlc-core-3.0.16-5.fc35.x86_64 vo-amrwbenc-0.1.3-15.fc35.x86_64 x264-libs-0.163-2.20210613git5db6aa6.fc35.x86_64 x265-libs-3.5-2.fc35.x86_64 xvidcore-1.3.7-6.fc35.x86_64
(gdb) bt
#0  0x00007fffe8834a95 in plugin_port_event (handle=0xf066000, port_index=<optimized out>, buffer_size=<optimized out>, format=<optimized out>, buffer=<optimized out>) at fluida_ui.c:457
#1  0x0000000000ab3620 in  ()
#2  0x0000000000ab3809 in  ()
#3  0x000000000054da72 in  ()
#4  0x000000000054f0cc in  ()
#5  0x00000000007d369d in  ()
#6  0x00007ffff76ed836 in  () at /opt/REAPER/libSwell.so
#7  0x00007ffff76e0b47 in  () at /opt/REAPER/libSwell.so
#8  0x00007ffff76edc97 in  () at /opt/REAPER/libSwell.so
#9  0x000000000040d5a6 in  ()
#10 0x00007ffff799c560 in __libc_start_call_main (main=main@entry=0x40cbe0, argc=argc@entry=1, argv=argv@entry=0x7fffffffdc98) at ../sysdeps/nptl/libc_start_call_main.h:58
#11 0x00007ffff799c60c in __libc_start_main_impl (main=0x40cbe0, argc=1, argv=0x7fffffffdc98, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdc88)
    at ../csu/libc-start.c:409
#12 0x000000000041a44a in _start ()

But seems to be the same issue. If I comment out these lines then Fluida seems to work!

brummer10 commented 2 years ago

Nice Catch. I'll investigate when I'm back at Weekend.

brummer10 commented 2 years ago

The issue was that I've updated libxputty and there I've changed the pointerps->dia->parent_struct to ps->dia->private_struct and forgot to change that in fluida_ui.c Should be fixed now.

KeithSBB commented 2 years ago

Yep, That fixed it. Thanks!