Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lv2 worker - Segmentation fault #6946

Closed
zonkmachine opened this issue Oct 22, 2023 · 3 comments · Fixed by #6947
Closed

Lv2 worker - Segmentation fault #6946

zonkmachine opened this issue Oct 22, 2023 · 3 comments · Fixed by #6947
Assignees
Labels
Milestone

Comments

@zonkmachine
Copy link
Member

These plugins were tested and known to work during the work with Lv2-worker but prior to merge the commits were cleaned up and this may have been when something broke and they will no longer load.

amsynth
Black Pearl Drumkit
Red Zeppelin Drumkit
setBfree DSP Tonewheel Organ

The backtraces are pretty much identical. Included is the one for amsynth

Thread 38 "lmms::Instrumen" received signal SIGSEGV, Segmentation fault.

Click to expand
Thread 38 "lmms::Instrumen" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffea7fc640 (LWP 5692)]
0x00005555558e3beb in lilv_instance_get_extension_data (instance=0x0, uri=0x555555ab2eb0 "http://lv2plug.in/ns/ext/worker#interface") at /usr/include/lilv-0/lilv/lilv.h:1974
1974	  if (instance->lv2_descriptor->extension_data) {
(gdb) bt full
#0  0x00005555558e3beb in lilv_instance_get_extension_data(LilvInstance const*, char const*) (instance=0x0, uri=0x555555ab2eb0 "http://lv2plug.in/ns/ext/worker#interface")
    at /usr/include/lilv-0/lilv/lilv.h:1974
#1  0x00005555558e5ba7 in lmms::Lv2Proc::initPluginSpecificFeatures() (this=0x7fffd4003f80) at /home/zonkmachine/builds/lmms/src/core/lv2/Lv2Proc.cpp:538
        iface = 0x7fffd4039f60
        threaded = false
        mgr = 0x55555687be80
#2  0x00005555558e5672 in lmms::Lv2Proc::initPlugin() (this=0x7fffd4003f80) at /home/zonkmachine/builds/lmms/src/core/lv2/Lv2Proc.cpp:441
        __PRETTY_FUNCTION__ = "void lmms::Lv2Proc::initPlugin()"
#3  0x00005555558e4701 in lmms::Lv2Proc::Lv2Proc(LilvPluginImpl const*, lmms::Model*) (this=0x7fffd4003f80, plugin=0x555556ad0b60, parent=0x7fff78130080)
    at /home/zonkmachine/builds/lmms/src/core/lv2/Lv2Proc.cpp:200
#4  0x00005555558dc205 in std::make_unique(LilvPluginImpl const*&, lmms::Model*&) () at /usr/include/c++/11/bits/unique_ptr.h:962
#5  0x00005555558db23f in lmms::Lv2ControlBase::init(lmms::Model*) (this=0x7fff781300e8, meAsModel=0x7fff78130080) at /home/zonkmachine/builds/lmms/src/core/lv2/Lv2ControlBase.cpp:79
        newOne = std::unique_ptr = {get() = 0x7fffd4003ed0}
        channelsLeft = 2
        __PRETTY_FUNCTION__ = "void lmms::Lv2ControlBase::init(lmms::Model*)"
#6  0x00005555558db0ad in lmms::Lv2ControlBase::Lv2ControlBase(lmms::Model*, QString const&) (this=0x7fff781300e8, that=0x7fff78130080, uri=...)
    at /home/zonkmachine/builds/lmms/src/core/lv2/Lv2ControlBase.cpp:57
#7  0x00007fff79a21cbd in lmms::Lv2Instrument::Lv2Instrument(lmms::InstrumentTrack*, lmms::Plugin::Descriptor::SubPluginFeatures::Key*)
    (this=0x7fff78130080, instrumentTrackArg=0x7ffff27eba80, key=0x7fffea7fbbd0) at /home/zonkmachine/builds/lmms/plugins/Lv2Instrument/Lv2Instrument.cpp:77
#8  0x00007fff79a22b0e in lmms::lmms_plugin_main(lmms::Model*, void*) (_parent=0x7ffff27eba80, _data=0x7fffea7fbbd0) at /home/zonkmachine/builds/lmms/plugins/Lv2Instrument/Lv2Instrument.cpp:315
        ins = 0x22866ad1e3804400
#9  0x0000555555881df1 in lmms::Plugin::instantiate(QString const&, lmms::Model*, void*) (pluginName=..., parent=0x7ffff27eba80, data=0x7fffea7fbbd0) at /home/zonkmachine/builds/lmms/src/core/Plugin.cpp:232
        instantiationHook = 0x7fff79a22ad7 
              pi = @0x7fffea7fbb50: {file = {d_ptr = {d = 0x55555c00d7a0}}, library = std::shared_ptr<QLibrary> (use count 3, weak count 0) = {get() = 0x55555c0638b0}, descriptor = 0x7fff79a2e700 <lv2instrument_plugin_descriptor>}
    inst = 0x55555582b620 <QMap<QString, QString>::QMap(QMap<QString, QString> const&)+36>

#10 0x0000555555881aa2 in lmms::Plugin::instantiateWithKey(QString const&, lmms::Model*, lmms::Plugin::Descriptor::SubPluginFeatures::Key const*, bool)
(pluginName=..., parent=0x7ffff27eba80, key=0x0, keyFromDnd=true) at /home/zonkmachine/builds/lmms/src/core/Plugin.cpp:198
keyCopy = {desc = 0x7fff79a2e700 <lv2instrument_plugin_descriptor>, name = {d = 0x55555c079960}, attributes = {d = 0x7fffd4001330}}
keyPtr = 0x55555c06ad10

              pi = @0x7fffea7fbbf0: {file = {d_ptr = {d = 0x55555c00d7a0}}, library = std::shared_ptr<QLibrary> (use count 3, weak count 0) = {get() = 0x55555c0638b0}, descriptor = 0x7fff79a2e700 <lv2instrument_plugin_descriptor>}

#11 0x000055555584b75f in lmms::Instrument::instantiate(QString const&, lmms::InstrumentTrack*, lmms::Plugin::Descriptor::SubPluginFeatures::Key const*, bool)
(_plugin_name=..., _instrument_track=0x7ffff27eba80, key=0x0, keyFromDnd=true) at /home/zonkmachine/builds/lmms/src/core/Instrument.cpp:74
p = 0x5555558b4396 lmms::Track::lock()+34
#12 0x0000555555a4679a in lmms::InstrumentTrack::loadInstrument(QString const&, lmms::Plugin::Descriptor::SubPluginFeatures::Key const*, bool) (this=0x7ffff27eba80, _plugin_name=..., key=0x0, keyFromDnd=true)
at /home/zonkmachine/builds/lmms/src/tracks/InstrumentTrack.cpp:1048
#13 0x00005555559d2f30 in lmms::InstrumentLoaderThread::run() (this=0x55555d1177f0) at /home/zonkmachine/builds/lmms/src/gui/editors/TrackContainerView.cpp:66
i = 0x0
parent = 0x22866ad1e3804400
#14 0x00007ffff6423ca1 in () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#15 0x00007ffff5e90ac3 in start_thread (arg=) at ./nptl/pthread_create.c:442
ret =
pd =

                  unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140737488338144, 3268165398512743456, 140737127630400, 11, 140737319077840, 140737488338496, -3268188490322201568, -3268152287426431968}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
    not_first_call = <optimized out>

--Type for more, q to quit, c to continue without paging--
#16 0x00007ffff5f22a40 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
(gdb)

@JohannesLorenz
Copy link
Contributor

Confirming your observation. Error introduced in last rework of Lv2Worker, in 583e3ac .

@JohannesLorenz
Copy link
Contributor

Analysis:

const auto iface = static_cast<const LV2_Worker_Interface*>(
	lilv_instance_get_extension_data(m_instance, LV2_WORKER__interface));

The mentioned commit now calls this in Lv2Proc::initPluginSpecificFeatures, before calling

m_instance = lilv_plugin_instantiate(m_plugin,
		Engine::audioEngine()->processingSampleRate(),
		m_features.featurePointers());

in Lv2Proc::initPlugin. Thus, operating on a nullptr.

JohannesLorenz added a commit to JohannesLorenz/lmms that referenced this issue Oct 22, 2023
JohannesLorenz added a commit to JohannesLorenz/lmms that referenced this issue Oct 22, 2023
This delays passing the `LV2_Worker_Interface` to the `Lv2Worker` class,
because prior to the patch, the instance, which provides the interface,
has not been initialized yet, which resulted in a segfault.
@zonkmachine
Copy link
Member Author

#6947 seem to have fixed it. All the plugins mentioned above now loads. I'll test it properly tomorrow.

@sakertooth sakertooth linked a pull request Oct 25, 2023 that will close this issue
messmerd added a commit that referenced this issue Oct 27, 2023
* Lv2Proc: Delay worker iface (Fixes #6946) (#6947)

This delays passing the `LV2_Worker_Interface` to the `Lv2Worker` class,
because prior to the patch, the instance, which provides the interface,
has not been initialized yet, which resulted in a segfault.

* Update src/core/lv2/Lv2Worker.cpp

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* setIface -> setInterface

* `if(` -> `if (`

* Update src/core/lv2/Lv2Proc.cpp

Co-authored-by: saker <sakertooth@gmail.com>

* Rework, editorial, from @sakertooth

* Fixup: `interface` is reserved on MSVC

https://stackoverflow.com/a/25234279

* Apply suggestions from code review

Co-authored-by: saker <sakertooth@gmail.com>

* Initialize handle/interface as nullptr

---------

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>
Co-authored-by: saker <sakertooth@gmail.com>
@github-project-automation github-project-automation bot moved this from To do to Done in Add LV2 support Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants