ossia / score

ossia score, an interactive sequencer for the intermedia arts
https://ossia.io
Other
1.45k stars 101 forks source link

Segfault (crash) when running JS snipplet #1507

Open edumeneses opened 3 months ago

edumeneses commented 3 months ago

ossia score crashes when I try to run a JS snippet to map 2 devices.

My error dump:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007a764b00e899 in QV4::PersistentValueStorage::allocate() () from /usr/lib/x86_64-linux-gnu/libQt6Qml.so.6
[Current thread is 1 (Thread 0x7a76315b3640 (LWP 205828))]
(gdb) bt
#0  0x00007a764b00e899 in QV4::PersistentValueStorage::allocate() () at /usr/lib/x86_64-linux-gnu/libQt6Qml.so.6
#1  0x00007a764af7316e in QJSEngine::create(QMetaType, void const*) () at /usr/lib/x86_64-linux-gnu/libQt6Qml.so.6
#2  0x00007a7568b24215 in QJSEngine::toScriptValue<JS::TokenRequestValueType>(JS::TokenRequestValueType const&) (this=0x7a7534172800, value=...)
    at /usr/include/x86_64-linux-gnu/qt6/QtQml/qjsengine.h:95
#3  0x00007a7568b1ef9c in JS::js_node::run(ossia::token_request const&, ossia::exec_state_facade) (this=0x5bb85da2e800, tk=..., estate=...)
    at /home/edu/Documents/sources/score/src/plugins/score-plugin-js/JS/Executor/CPUNode.cpp:257
#4  0x00007a764cb7fb1a in ossia::graph_util::exec_node(ossia::graph_node&, ossia::execution_state&) (first_node=..., e=...)
    at /home/edu/Documents/sources/score/3rdparty/libossia/src/ossia/dataflow/graph/graph_utils.hpp:587
#5  0x00007a764cbfc752 in ossia::node_exec::operator()(ossia::graph_node&) (this=0x5bb85f2ad050, node=...)
    at /home/edu/Documents/sources/score/3rdparty/libossia/src/ossia/dataflow/graph/node_executors.hpp:17
#6  0x00007a764cbfc6ba in smallfun::function<void (ossia::graph_node&), 32ul, 8ul, (smallfun::Methods)2>::function<ossia::node_exec, void>(ossia::node_exec&&)::{lambda(void*, ossia::graph_
node&)#1}::operator()(void*, ossia::graph_node&) const (this=0x5bb85f2ad050, self=0x5bb85f2ad050, xs=...)
    at /home/edu/Documents/sources/score/3rdparty/libossia/3rdparty/SmallFunction/smallfun/include/smallfun.hpp:360
#7  0x00007a764cbfc683 in smallfun::function<void (ossia::graph_node&), 32ul, 8ul, (smallfun::Methods)2>::function<ossia::node_exec, void>(ossia::node_exec&&)::{lambda(void*, ossia::graph_
node&)#1}::__invoke(void*, ossia::graph_node&) (self=0x5bb85f2ad050, xs=...)
    at /home/edu/Documents/sources/score/3rdparty/libossia/3rdparty/SmallFunction/smallfun/include/smallfun.hpp:358
#8  0x00007a764cbec803 in smallfun::function<void (ossia::graph_node&), 32ul, 8ul, (smallfun::Methods)2>::operator()<ossia::graph_node&>(ossia::graph_node&) (this=0x5bb85f2ad048, ys=...)
    at /home/edu/Documents/sources/score/3rdparty/libossia/3rdparty/SmallFunction/smallfun/include/smallfun.hpp:460
#9  0x00007a764cbe9cfd in ossia::executor::execute(ossia::task&) (this=0x5bb85f2ad048, task=...)
    at /home/edu/Documents/sources/score/3rdparty/libossia/src/ossia/dataflow/graph/graph_parallel_impl.hpp:307
#10 0x00007a764cbfeb66 in ossia::executor::run(ossia::taskflow&) (this=0x5bb85f2ad048, tf=...)
    at /home/edu/Documents/sources/score/3rdparty/libossia/src/ossia/dataflow/graph/graph_parallel_impl.hpp:22
jcelerier commented 1 month ago

Most likely this is due to QJSEngine not being thread-safe and things crashing when running the DSP graph in threaded mode. Mitigation : add the ability to mark nodes as not-thread-safe so that they always get scheduled on the execution thread 0 and not any random other.