calf icon indicating copy to clipboard operation
calf copied to clipboard

gui crashes in audacity

Open cfra opened this issue 6 years ago • 10 comments

I am currently trying to fix Audacity so that it can load recent Calf plugins again. While I think that I got the loading part right, rendering the gui now crashes Audacity.

The crash happens in toggle_param_control::create at the following code:

    widget  = calf_toggle_new ();
    CalfToggle * toggle = CALF_TOGGLE(widget);
    calf_toggle_set_size(toggle, get_int("size", 2));

calf_toggle_new returns NULL, causing calf_toggle_set_size to crash the program, since it's dereferencing NULL.

Unfortunately, I am not very familiar with GTK/Gobject, so I am not sure why this is happening. Below is a gdb session, tracing through the problematic part.

Thread 1 "audacity" hit Breakpoint 1, calf_toggle_new () at ctl_buttons.cpp:131
131	    GtkAdjustment *adj = (GtkAdjustment *)gtk_adjustment_new(0, 0, 1, 1, 0, 0);
(gdb) next
132	    return calf_toggle_new_with_adjustment(adj);
(gdb) print adj
$2 = 0x5555574c4bd0
(gdb) step
calf_toggle_new_with_adjustment (_adjustment=0x5555574c4bd0) at ctl_buttons.cpp:151
151	    GtkWidget *widget = GTK_WIDGET( g_object_new (CALF_TYPE_TOGGLE, NULL ));
(gdb) next

(Audacity:14512): GLib-GObject-WARNING **: specified class size for type 'CalfToggle' is smaller than the parent type's 'GtkRange' class size

(Audacity:14512): GLib-GObject-CRITICAL **: g_object_new_with_properties: assertion 'G_TYPE_IS_OBJECT (object_type)' failed
152	    if (widget) {
(gdb) print widget
$3 = 0x0
(gdb) finish
Run till exit from #0  calf_toggle_new_with_adjustment (_adjustment=0x5555574c4bd0) at ctl_buttons.cpp:152
[Thread 0x7fffc6ffd700 (LWP 14604) exited]
calf_toggle_new () at ctl_buttons.cpp:133
133	}
Value returned is $4 = 0x0
(gdb) next
calf_plugins::toggle_param_control::create (this=0x555557c7f7b0, _gui=0x555557c7fb00, _param_no=0) at gui_controls.cpp:927
927	    CalfToggle * toggle = CALF_TOGGLE(widget);
(gdb) 

(Audacity:14512): GLib-GObject-WARNING **: specified class size for type 'CalfToggle' is smaller than the parent type's 'GtkRange' class size
928	    calf_toggle_set_size(toggle, get_int("size", 2));
(gdb) 

Thread 1 "audacity" received signal SIGSEGV, Segmentation fault.
0x00007fffb9d52aee in calf_toggle_set_size (self=0x0, size=2) at ctl_buttons.cpp:115
115	    self->size = size;
(gdb) 
0x00007ffff5776670 in ?? () from /usr/lib/libwx_baseu-3.0.so.0
(gdb)

Full backtrace of the crash would be:

#0  0x00007fffb9d52aee in calf_toggle_set_size(CalfToggle*, int) (self=0x0, size=2) at ctl_buttons.cpp:115
#1  0x00007fffb9d34ccb in calf_plugins::toggle_param_control::create(calf_plugins::plugin_gui*, int) (this=0x555557c6b850, _gui=0x555557c6c960, _param_no=0) at gui_controls.cpp:928
#2  0x00007fffb9d2f9bf in calf_plugins::param_control::create(calf_plugins::plugin_gui*) (this=0x555557c6b850, _gui=0x555557c6c960) at gui_controls.cpp:140
#3  0x00007fffb9d183f5 in calf_plugins::plugin_gui::xml_element_start(char const*, char const**) (this=0x555557c6c960, element=0x555557c9496c "toggle", attributes=0x555556c69470) at gui.cpp:173
#4  0x00007fffb9d17efc in calf_plugins::plugin_gui::xml_element_start(void*, char const*, char const**) (data=0x555557c6c960, element=0x555557c9496c "toggle", attributes=0x555556c69400) at gui.cpp:123
#5  0x00007ffff7bb0c2b in  () at /usr/lib/libexpat.so.1
#6  0x00007ffff7bb1dac in  () at /usr/lib/libexpat.so.1
#7  0x00007ffff7baf9f3 in  () at /usr/lib/libexpat.so.1
#8  0x00007ffff7bb06b5 in  () at /usr/lib/libexpat.so.1
#9  0x00007ffff7bb429d in XML_ParseBuffer () at /usr/lib/libexpat.so.1
#10 0x00007fffb9d18847 in calf_plugins::plugin_gui::create_from_xml(calf_plugins::plugin_ctl_iface*, char const*) (this=0x555557c6c960, _plugin=
    0x55555757e640, xml=0x555557c95470 "<vbox spacing=\"10\">\n    <table rows=\"4\" cols=\"7\">\n        <label param=\"bypass\" attach-x=\"0\" attach-y=\"0\" expand-x=\"0\" fill-x=\"0\" />\n        <toggle param=\"bypass\" icon=\"bypass\" attach-x=\"0\" attach-y="...) at gui.cpp:218
#11 0x00007fffb9d84fb6 in gui_instantiate(_LV2UI_Descriptor const*, char const*, char const*, void (*)(void*, unsigned int, unsigned int, unsigned int, void const*), void*, void**, _LV2_Feature const* const*) (descriptor=0x7fffb9ffe000 <lv2ui_descriptor::gtkgui>, plugin_uri=0x555556be9d30 "http://calf.sourceforge.net/plugins/BassEnhancer", bundle_path=0x555556932da7 "/usr/lib/lv2/calf.lv2/", write_function=0x555555e8ea10 <LV2Effect::suil_write_func(void*, unsigned int, unsigned int, unsigned int, void const*)>, controller=0x555556e1b800, widget=0x555557c92810, features=0x555557c928b0) at lv2gui.cpp:361
#12 0x00007ffff335e5cb in suil_instance_new () at /usr/lib/libsuil-0.so.0
#13 0x0000555555e92d42 in LV2Effect::BuildFancy() ()
#14 0x0000555555e95290 in LV2Effect::PopulateUI(wxWindow*) ()
#15 0x0000555555c42b69 in EffectUIHost::Initialize() ()
#16 0x0000555555c441a8 in Effect::CreateUI(wxWindow*, EffectUIClientInterface*) ()
#17 0x0000555555e8e3c3 in LV2Effect::ShowInterface(wxWindow*, bool) ()
#18 0x0000555555c32735 in Effect::ShowInterface(wxWindow*, bool) ()
#19 0x0000555555c3ff11 in Effect::DoEffect(wxWindow*, double, TrackList*, TrackFactory*, SelectedRegion*, bool) ()
#20 0x0000555555ab86f7 in AudacityProject::DoEffect(wxString const&, CommandContext const&, int) ()
#21 0x0000555555ba2d5b in CommandManager::HandleCommandEntry(CommandListEntry const*, CommandFlag, CommandFlag, wxEvent const*) ()
#22 0x0000555555ba8a64 in CommandManager::HandleMenuID(int, CommandFlag, CommandFlag) ()
#23 0x0000555555ae607b in AudacityProject::OnMenu(wxCommandEvent&) ()
#24 0x00007ffff57a0d4e in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#25 0x00007ffff57a0e54 in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () at /usr/lib/libwx_baseu-3.0.so.0
#26 0x00007ffff57a122d in wxEvtHandler::TryHereOnly(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#27 0x00007ffff57a1013 in wxEvtHandler::DoTryChain(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#28 0x00007ffff57a1316 in wxEvtHandler::ProcessEvent(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#29 0x00007ffff62d1d5b in wxWindowBase::TryAfter(wxEvent&) () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#30 0x00007ffff57a1067 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#31 0x00007ffff6283d50 in wxMenuBase::SendEvent(int, int) () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#32 0x00007ffff616ef8c in  () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#33 0x00007ffff0d2c6f5 in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#34 0x00007ffff0d400b0 in  () at /usr/lib/libgobject-2.0.so.0
#35 0x00007ffff0d44696 in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#36 0x00007ffff0d45920 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#37 0x00007ffff2764099 in gtk_widget_activate () at /usr/lib/libgtk-3.so.0
#38 0x00007ffff262b86d in gtk_menu_shell_activate_item () at /usr/lib/libgtk-3.so.0
#39 0x00007ffff262bb09 in  () at /usr/lib/libgtk-3.so.0
#40 0x00007ffff260e488 in  () at /usr/lib/libgtk-3.so.0
#41 0x00007ffff0d44c01 in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#42 0x00007ffff0d45920 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#43 0x00007ffff27619e5 in  () at /usr/lib/libgtk-3.so.0
#44 0x00007ffff260b1eb in  () at /usr/lib/libgtk-3.so.0
#45 0x00007ffff260d443 in gtk_main_do_event () at /usr/lib/libgtk-3.so.0
#46 0x00007ffff21159f6 in  () at /usr/lib/libgdk-3.so.0
#47 0x00007ffff2148375 in  () at /usr/lib/libgdk-3.so.0
#48 0x00007ffff0a5c270 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#49 0x00007ffff0a5df69 in  () at /usr/lib/libglib-2.0.so.0
#50 0x00007ffff0a5ef42 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
#51 0x00007ffff260c50f in gtk_main () at /usr/lib/libgtk-3.so.0

If you can warrant any guesses what is going wrong here, please let me know.

cfra avatar May 01 '18 16:05 cfra

Hm, no idea ootb. I just checked the code regarding registering GObject types, seems okay to me. It would be interesting to know if it's just the toggle button or all complex widget types triggering the problem. I guess you tried bass enhancer? If so please try to edit [install path]/share/calf/gui/bassenhancer.xml, remove line #3 instantiating the bypass toggle button and try again.

boomshop avatar May 01 '18 18:05 boomshop

Yea, I tried the bass enhancer. The problem seems to be with other complex widgets too apparently. Following your advice and removing the bypass toggle, it crashes like this:

CALF DEBUG: instance 0x55555714b980 data 0x555556652b20
CALF DEBUG: calf 0x7fffbb0d2240 cpi 0x7fffba6b9fa8

(Audacity:31710): GLib-GObject-WARNING **: invalid cast from 'GtkLabel' to 'GtkObject'

(Audacity:31710): GLib-GObject-WARNING **: invalid cast from 'GtkLabel' to 'GtkObject'

(Audacity:31710): GLib-GObject-WARNING **: specified class size for type 'CalfKnob' is smaller than the parent type's 'GtkRange' class size

(Audacity:31710): GLib-GObject-CRITICAL **: g_object_new_with_properties: assertion 'G_TYPE_IS_OBJECT (object_type)' failed

(Audacity:31710): Gtk-CRITICAL **: gtk_widget_set_name: assertion 'GTK_IS_WIDGET (widget)' failed

(Audacity:31710): GLib-GObject-WARNING **: specified class size for type 'CalfKnob' is smaller than the parent type's 'GtkRange' class size

(Audacity:31710): Gtk-CRITICAL **: gtk_range_get_adjustment: assertion 'GTK_IS_RANGE (range)' failed

Thread 1 "audacity" received signal SIGSEGV, Segmentation fault.
0x00007fffb95e418f in calf_plugins::knob_param_control::create (this=0x55555714b4d0, _gui=0x5555570cb5c0, _param_no=1) at gui_controls.cpp:867
(gdb) bt
#0  0x00007fffb95e418f in calf_plugins::knob_param_control::create(calf_plugins::plugin_gui*, int) (this=0x55555714b4d0, _gui=0x5555570cb5c0, _param_no=1) at gui_controls.cpp:867
#1  0x00007fffb95df77f in calf_plugins::param_control::create(calf_plugins::plugin_gui*) (this=0x55555714b4d0, _gui=0x5555570cb5c0) at gui_controls.cpp:140
#2  0x00007fffb95c81b5 in calf_plugins::plugin_gui::xml_element_start(char const*, char const**) (this=0x5555570cb5c0, element=0x555558171b8c "knob", attributes=0x5555570ef4d0) at gui.cpp:173
#3  0x00007fffb95c7cbc in calf_plugins::plugin_gui::xml_element_start(void*, char const*, char const**) (data=0x5555570cb5c0, element=0x555558171b8c "knob", attributes=0x5555570ef460) at gui.cpp:123
#4  0x00007ffff7bb0c2b in  () at /usr/lib/libexpat.so.1
#5  0x00007ffff7bb1dac in  () at /usr/lib/libexpat.so.1
#6  0x00007ffff7baf9f3 in  () at /usr/lib/libexpat.so.1
#7  0x00007ffff7bb06b5 in  () at /usr/lib/libexpat.so.1
#8  0x00007ffff7bb429d in XML_ParseBuffer () at /usr/lib/libexpat.so.1
#9  0x00007fffb95c8607 in calf_plugins::plugin_gui::create_from_xml(calf_plugins::plugin_ctl_iface*, char const*) (this=0x5555570cb5c0, _plugin=
    0x55555708ba00, xml=0x5555583641b0 "<vbox spacing=\"10\">\n    <table rows=\"4\" cols=\"7\">\n        <!--<label param=\"bypass\" attach-x=\"0\" attach-y=\"0\" expand-x=\"0\" fill-x=\"0\" />\n        <toggle param=\"bypass\" icon=\"bypass\" attach-x=\"0\" attac"...) at gui.cpp:218
#10 0x00007fffb963748c in gui_instantiate(_LV2UI_Descriptor const*, char const*, char const*, void (*)(void*, unsigned int, unsigned int, unsigned int, void const*), void*, void**, _LV2_Feature const* const*) (descriptor=0x7fffb98b12e0 <lv2ui_descriptor::gtkgui>, plugin_uri=0x555556998b80 "http://calf.sourceforge.net/plugins/BassEnhancer", bundle_path=0x55555687a7a7 "/usr/lib/lv2/calf.lv2/", write_function=0x555555e8ea10 <LV2Effect::suil_write_func(void*, unsigned int, unsigned int, unsigned int, void const*)>, controller=0x555556652900, widget=0x5555570e9a80, features=0x555558365b00) at lv2gui.cpp:361
#11 0x00007ffff335e5cb in suil_instance_new () at /usr/lib/libsuil-0.so.0
#12 0x0000555555e92d42 in LV2Effect::BuildFancy() ()
#13 0x0000555555e95290 in LV2Effect::PopulateUI(wxWindow*) ()
#14 0x0000555555c42b69 in EffectUIHost::Initialize() ()
#15 0x0000555555c441a8 in Effect::CreateUI(wxWindow*, EffectUIClientInterface*) ()
#16 0x0000555555e8e3c3 in LV2Effect::ShowInterface(wxWindow*, bool) ()
#17 0x0000555555c32735 in Effect::ShowInterface(wxWindow*, bool) ()
#18 0x0000555555c3ff11 in Effect::DoEffect(wxWindow*, double, TrackList*, TrackFactory*, SelectedRegion*, bool) ()
#19 0x0000555555ab86f7 in AudacityProject::DoEffect(wxString const&, CommandContext const&, int) ()
#20 0x0000555555ba2d5b in CommandManager::HandleCommandEntry(CommandListEntry const*, CommandFlag, CommandFlag, wxEvent const*) ()
#21 0x0000555555ba8a64 in CommandManager::HandleMenuID(int, CommandFlag, CommandFlag) ()
#22 0x0000555555ae607b in AudacityProject::OnMenu(wxCommandEvent&) ()
#23 0x00007ffff57a0d4e in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#24 0x00007ffff57a0e54 in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () at /usr/lib/libwx_baseu-3.0.so.0
#25 0x00007ffff57a122d in wxEvtHandler::TryHereOnly(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#26 0x00007ffff57a1013 in wxEvtHandler::DoTryChain(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#27 0x00007ffff57a1316 in wxEvtHandler::ProcessEvent(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#28 0x00007ffff62d1d5b in wxWindowBase::TryAfter(wxEvent&) () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#29 0x00007ffff57a1067 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#30 0x00007ffff6283d50 in wxMenuBase::SendEvent(int, int) () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#31 0x00007ffff616ef8c in  () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#32 0x00007ffff0d2c6f5 in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#33 0x00007ffff0d400b0 in  () at /usr/lib/libgobject-2.0.so.0
#34 0x00007ffff0d44696 in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#35 0x00007ffff0d45920 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#36 0x00007ffff2764099 in gtk_widget_activate () at /usr/lib/libgtk-3.so.0
#37 0x00007ffff262b86d in gtk_menu_shell_activate_item () at /usr/lib/libgtk-3.so.0
#38 0x00007ffff262bb09 in  () at /usr/lib/libgtk-3.so.0
#39 0x00007ffff260e488 in  () at /usr/lib/libgtk-3.so.0
#40 0x00007ffff0d44c01 in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#41 0x00007ffff0d45920 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#42 0x00007ffff27619e5 in  () at /usr/lib/libgtk-3.so.0
#43 0x00007ffff260b1eb in  () at /usr/lib/libgtk-3.so.0
#44 0x00007ffff260d443 in gtk_main_do_event () at /usr/lib/libgtk-3.so.0
#45 0x00007ffff21159f6 in  () at /usr/lib/libgdk-3.so.0
#46 0x00007ffff2148375 in  () at /usr/lib/libgdk-3.so.0
#47 0x00007ffff0a5c270 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#48 0x00007ffff0a5df69 in  () at /usr/lib/libglib-2.0.so.0
#49 0x00007ffff0a5ef42 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
#50 0x00007ffff260c50f in gtk_main () at /usr/lib/libgtk-3.so.0
#51 0x00007ffff60f4c06 in wxGUIEventLoop::DoRun() () at /usr/lib/libwx_gtk3u_core-3.0.so.0
---Type <return> to continue, or q <return> to quit---
#52 0x00007ffff5656784 in wxEventLoopBase::Run() () at /usr/lib/libwx_baseu-3.0.so.0
#53 0x00007ffff561d247 in wxAppConsoleBase::MainLoop() () at /usr/lib/libwx_baseu-3.0.so.0
#54 0x00007ffff56aa578 in wxEntry(int&, wchar_t**) () at /usr/lib/libwx_baseu-3.0.so.0
#55 0x000055555596f771 in main ()
(gdb) 

cfra avatar May 01 '18 18:05 cfra

Now CalfKnob seems to crash which is the second (and last) widget based on GtkRange. There's a warning that the size of the parent element GtkRange and the new object differ (as I said, code seems okay). Could you please try removing all knobs from the UI definition to see if the inheritance of GtkRange fails or if other widgets crash, too? Then there should be some labels, faders, level meters and other minor widgets left.

boomshop avatar May 01 '18 18:05 boomshop

Seems to concern all widgets. Have removed all knobs and toggles now and this is the result:

CALF DEBUG: instance 0x555557445600 data 0x555556d61d20
CALF DEBUG: calf 0x7fffbb81e240 cpi 0x7fffbae05fa8

(Audacity:1578): GLib-GObject-WARNING **: invalid cast from 'GtkLabel' to 'GtkObject'

(Audacity:1578): GLib-GObject-WARNING **: invalid cast from 'GtkLabel' to 'GtkObject'

(Audacity:1578): GLib-GObject-WARNING **: specified class size for type 'CalfVUMeter' is smaller than the parent type's 'GtkDrawingArea' class size

(Audacity:1578): GLib-GObject-CRITICAL **: g_object_new_with_properties: assertion 'G_TYPE_IS_OBJECT (object_type)' failed

(Audacity:1578): GLib-GObject-WARNING **: specified class size for type 'CalfVUMeter' is smaller than the parent type's 'GtkDrawingArea' class size

(Audacity:1578): Gtk-CRITICAL **: gtk_widget_set_name: assertion 'GTK_IS_WIDGET (widget)' failed

Thread 1 "audacity" received signal SIGSEGV, Segmentation fault.
0x00007fffb9d4e095 in calf_vumeter_set_mode (meter=0x0, mode=VU_STANDARD) at ctl_vumeter.cpp:504

cfra avatar May 01 '18 18:05 cfra

As a side note: I just loaded the bass enhancer in calfjackhost and its gui renders fine there. So I would guess it's not a general issue but somehow specific to the way it's being run in Audacity.

cfra avatar May 01 '18 18:05 cfra

No, it's not general, Calf runs fine in all other hosts like Ardour and Carla.

boomshop avatar May 01 '18 18:05 boomshop

@falkTX @kfoltman any of you guys have an idea?

boomshop avatar May 01 '18 18:05 boomshop

I might have miswritten. The calfjackhost info was just to rule out a general problem with my build. I know that Calf usually works very well :)

cfra avatar May 01 '18 18:05 cfra

Any news on this? Any more useful information which I could provide?

cfra avatar May 15 '18 15:05 cfra

Not from my side, sorry. If 0.0.60 works and the latest doesn't you could try figuring out which commit introduced the problem. Then I could take a closer look into the changes on our side. Probably this leads to some kind of enlightenment.

boomshop avatar May 15 '18 17:05 boomshop