Application: amarok (2.9.71) Qt Version: 5.15.8 Frameworks Version: 5.103.0 Operating System: Linux 5.14.21-150500.55.36-default x86_64 Windowing System: X11 Distribution: "openSUSE Leap 15.5" DrKonqi: 5.27.9 [KCrashBackend] -- Information about the crash: Script error reported by: TypeError Cannot call method 'connect' of undefined The reporter is unsure if this crash is reproducible. -- Backtrace: Application: Amarok (amarok), signal: Segmentation fault [KCrash Handler] #14 0x00007fe6f8aa79ca in QV4::WeakValue::isUndefined() const (this=0x562ccfa5fe30) at ../../include/QtQml/5.15.8/QtQml/private/../../../../../../src/qml/jsruntime/qv4persistent_p.h:202 #15 QV4::QObjectWrapper::wrap_slowPath(QV4::ExecutionEngine*, QObject*) (engine=engine@entry=0x562cd03df000, object=object@entry=0x562ccfa5fdc0) at /usr/src/debug/libqt5-qtdeclarative-5.15.8+kde22-150500.1.2.x86_64/src/qml/jsruntime/qv4qobjectwrapper.cpp:594 #16 0x00007fe6f8a0caf5 in QV4::QObjectWrapper::wrap(QV4::ExecutionEngine*, QObject*) (object=0x562ccfa5fdc0, engine=0x562cd03df000) at ../../include/QtQml/5.15.8/QtQml/private/../../../../../../src/qml/jsruntime/qv4qobjectwrapper_p.h:222 #17 QJSEngine::newQObject(QObject*) (this=this@entry=0x562cd0536c50, object=0x562ccfa5fdc0) at /usr/src/debug/libqt5-qtdeclarative-5.15.8+kde22-150500.1.2.x86_64/src/qml/jsapi/qjsengine.cpp:697 #18 0x00007fe705aa4d1f in AmarokScript::TrackSetExporter::init(QJSEngine*) (engine=engine@entry=0x562cd0536c50) at /usr/src/debug/amarok-2.9.75git.20230408T114133~7098c192a6-lp155.173.13.x86_64/src/scripting/scriptengine/exporters/ScriptableBiasExporter.cpp:457 #19 0x00007fe705aa5186 in AmarokScript::ScriptableBiasFactory::init(QJSEngine*) (engine=0x562cd0536c50) at /usr/src/debug/amarok-2.9.75git.20230408T114133~7098c192a6-lp155.173.13.x86_64/src/scripting/scriptengine/exporters/ScriptableBiasExporter.cpp:58 #20 0x00007fe705b6c2b1 in ScriptItem::initializeScriptEngine() (this=0x562cd04d8790) at /usr/src/debug/amarok-2.9.75git.20230408T114133~7098c192a6-lp155.173.13.x86_64/src/scripting/scriptmanager/ScriptItem.cpp:320 #21 0x00007fe705aae81c in ScriptConsoleNS::ScriptConsoleItem::ScriptConsoleItem(QObject*, QString const&, QString const&, QString const&, ScriptConsoleNS::ScriptEditorDocument*) (this=0x562cd04d8790, parent=0x562cd0301fc0, name=..., category=<optimized out>, path=..., document=0x562cd04b9de0) at /usr/src/debug/amarok-2.9.75git.20230408T114133~7098c192a6-lp155.173.13.x86_64/src/scripting/scriptconsole/ScriptConsoleItem.cpp:44 #22 0x00007fe705aa99da in ScriptConsoleNS::ScriptConsole::createScriptItem(QString const&) (this=this@entry=0x562cd0301fc0, script=...) at /usr/src/debug/amarok-2.9.75git.20230408T114133~7098c192a6-lp155.173.13.x86_64/src/scripting/scriptconsole/ScriptConsole.cpp:245 #23 0x00007fe705aaa4d6 in ScriptConsoleNS::ScriptConsole::slotNewScript() (this=this@entry=0x562cd0301fc0) at /usr/src/debug/amarok-2.9.75git.20230408T114133~7098c192a6-lp155.173.13.x86_64/src/scripting/scriptconsole/ScriptConsole.cpp:351 #24 0x00007fe705aac21a in ScriptConsoleNS::ScriptConsole::ScriptConsole(QWidget*) (this=0x562cd0301fc0, parent=<optimized out>) at /usr/src/debug/amarok-2.9.75git.20230408T114133~7098c192a6-lp155.173.13.x86_64/src/scripting/scriptconsole/ScriptConsole.cpp:161 #25 0x00007fe705aac516 in ScriptConsoleNS::ScriptConsole::instance() () at /usr/src/debug/amarok-2.9.75git.20230408T114133~7098c192a6-lp155.173.13.x86_64/src/scripting/scriptconsole/ScriptConsole.cpp:55 #26 0x00007fe705b384bd in App::applySettings() (this=0x7ffca5dd44d0) at /usr/src/debug/amarok-2.9.75git.20230408T114133~7098c192a6-lp155.173.13.x86_64/src/App.cpp:409 #27 0x00007fe704318a6b in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7ffca5dd32f0, r=0x7ffca5dd44d0, this=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398 #28 doActivate<false>(QObject*, int, void**) (sender=0x562cd0087de0, signal_index=13, argv=0x7ffca5dd32f0) at kernel/qobject.cpp:3923 #29 0x00007fe704311ee2 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=sender@entry=0x562cd0087de0, m=m@entry=0x7fe701216de0 <KConfigDialog::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7ffca5dd32f0) at kernel/qobject.cpp:3983 #30 0x00007fe7011e1035 in KConfigDialog::settingsChanged(QString const&) (this=this@entry=0x562cd0087de0, _t1=...) at /usr/src/debug/kconfigwidgets-5.103.0-150500.1.1.x86_64/build/src/KF5ConfigWidgets_autogen/include/moc_kconfigdialog.cpp:208 #31 0x00007fe7011e2713 in KConfigDialogPrivate::settingsChangedSlot() (this=<optimized out>) at /usr/src/debug/kconfigwidgets-5.103.0-150500.1.1.x86_64/src/kconfigdialog.cpp:295 #32 0x00007fe704318a6b in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7ffca5dd33e0, r=0x562cd0087de0, this=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398 #33 doActivate<false>(QObject*, int, void**) (sender=0x562cd01b0a70, signal_index=3, argv=0x7ffca5dd33e0) at kernel/qobject.cpp:3923 #34 0x00007fe704311ee2 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=sender@entry=0x562cd01b0a70, m=m@entry=0x7fe701216ea0 <KConfigDialogManager::staticMetaObject>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x0) at kernel/qobject.cpp:3983 #35 0x00007fe7011e4090 in KConfigDialogManager::settingsChanged() (this=this@entry=0x562cd01b0a70) at /usr/src/debug/kconfigwidgets-5.103.0-150500.1.1.x86_64/build/src/KF5ConfigWidgets_autogen/include/moc_kconfigdialogmanager.cpp:182 #36 0x00007fe7011e9bd6 in KConfigDialogManager::updateSettings() (this=0x562cd01b0a70) at /usr/src/debug/kconfigwidgets-5.103.0-150500.1.1.x86_64/src/kconfigdialogmanager.cpp:400 #37 0x00007fe704318a6b in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7ffca5dd35d0, r=0x562cd01b0a70, this=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398 #38 doActivate<false>(QObject*, int, void**) (sender=0x562cd01c7960, signal_index=9, argv=0x7ffca5dd35d0) at kernel/qobject.cpp:3923 #39 0x00007fe704311ee2 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=sender@entry=0x562cd01c7960, m=m@entry=0x7fe70537f180 <QAbstractButton::staticMetaObject>, local_signal_index=local_signal_index@entry=2, argv=argv@entry=0x7ffca5dd35d0) at kernel/qobject.cpp:3983 #40 0x00007fe704f7cdd2 in QAbstractButton::clicked(bool) (this=this@entry=0x562cd01c7960, _t1=<optimized out>) at .moc/moc_qabstractbutton.cpp:308 #41 0x00007fe704f7d05a in QAbstractButtonPrivate::emitClicked() (this=0x562cceff6ca0) at widgets/qabstractbutton.cpp:416 #42 0x00007fe704f7e4ba in QAbstractButtonPrivate::click() (this=0x562cceff6ca0) at widgets/qabstractbutton.cpp:409 #43 0x00007fe704f7e6ad in QAbstractButton::mouseReleaseEvent(QMouseEvent*) (this=0x562cd01c7960, e=0x7ffca5dd3b60) at widgets/qabstractbutton.cpp:1045 #44 0x00007fe704ed0da8 in QWidget::event(QEvent*) (this=0x562cd01c7960, event=0x7ffca5dd3b60) at kernel/qwidget.cpp:9045 #45 0x00007fe704f7ffcb in QAbstractButton::event(QEvent*) (this=this@entry=0x562cd01c7960, e=e@entry=0x7ffca5dd3b60) at widgets/qabstractbutton.cpp:1002 #46 0x00007fe70502223f in QPushButton::event(QEvent*) (this=0x562cd01c7960, e=0x7ffca5dd3b60) at widgets/qpushbutton.cpp:718 #47 0x00007fe704e9053c in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=this@entry=0x562cce1a6650, receiver=receiver@entry=0x562cd01c7960, e=e@entry=0x7ffca5dd3b60) at kernel/qapplication.cpp:3640 #48 0x00007fe704e97877 in QApplication::notify(QObject*, QEvent*) (this=<optimized out>, receiver=0x562cd01c7960, e=0x7ffca5dd3b60) at kernel/qapplication.cpp:3084 #49 0x00007fe7042db073 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x562cd01c7960, event=0x7ffca5dd3b60) at kernel/qcoreapplication.cpp:1064 #50 0x00007fe7042db25e in QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) (receiver=receiver@entry=0x562cd01c7960, event=event@entry=0x7ffca5dd3b60) at kernel/qcoreapplication.cpp:1474 #51 0x00007fe704e9687f in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) (receiver=receiver@entry=0x562cd01c7960, event=event@entry=0x7ffca5dd3b60, alienWidget=0x562cd01c7960, nativeWidget=0x562cd0087de0, buttonDown=buttonDown@entry=0x7fe7053b1330 <qt_button_down>, lastMouseReceiver=..., spontaneous=true, onlyDispatchEnterLeave=false) at kernel/qapplication.cpp:2622 #52 0x00007fe704eeb58c in QWidgetWindow::handleMouseEvent(QMouseEvent*) (this=this@entry=0x562cd0309990, event=event@entry=0x7ffca5dd3fb0) at kernel/qwidgetwindow.cpp:683 #53 0x00007fe704eee5fd in QWidgetWindow::event(QEvent*) (this=0x562cd0309990, event=0x7ffca5dd3fb0) at kernel/qwidgetwindow.cpp:300 #54 0x00007fe704e9053c in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=this@entry=0x562cce1a6650, receiver=receiver@entry=0x562cd0309990, e=e@entry=0x7ffca5dd3fb0) at kernel/qapplication.cpp:3640 #55 0x00007fe704e972ff in QApplication::notify(QObject*, QEvent*) (this=<optimized out>, receiver=0x562cd0309990, e=0x7ffca5dd3fb0) at kernel/qapplication.cpp:3164 #56 0x00007fe7042db073 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x562cd0309990, event=0x7ffca5dd3fb0) at kernel/qcoreapplication.cpp:1064 #57 0x00007fe7042db25e in QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) (receiver=receiver@entry=0x562cd0309990, event=event@entry=0x7ffca5dd3fb0) at kernel/qcoreapplication.cpp:1474 #58 0x00007fe70473adeb in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) (e=0x562cd02ff760) at kernel/qguiapplication.cpp:2285 #59 0x00007fe70473c095 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) (e=e@entry=0x562cd02ff760) at kernel/qguiapplication.cpp:2005 #60 0x00007fe704712b8b in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1169 #61 0x00007fe6f2b0f65a in xcbSourceDispatch(GSource*, GSourceFunc, gpointer) (source=<optimized out>) at qxcbeventdispatcher.cpp:105 #62 0x00007fe6f751d82b in g_main_context_dispatch () at /usr/lib64/libglib-2.0.so.0 #63 0x00007fe6f751dbd0 in () at /usr/lib64/libglib-2.0.so.0 #64 0x00007fe6f751dc5c in g_main_context_iteration () at /usr/lib64/libglib-2.0.so.0 #65 0x00007fe70433d9bc in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x562cce280770, flags=...) at kernel/qeventdispatcher_glib.cpp:423 #66 0x00007fe7042d98da in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7ffca5dd4350, flags=..., flags@entry=...) at kernel/qeventloop.cpp:235 #67 0x00007fe7042e3117 in QCoreApplication::exec() () at kernel/qcoreapplication.cpp:1375 #68 0x0000562ccd3c106f in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/amarok-2.9.75git.20230408T114133~7098c192a6-lp155.173.13.x86_64/src/main.cpp:395 [Inferior 1 (process 32401) detached] Reported using DrKonqi
A possibly relevant merge request was started @ https://invent.kde.org/multimedia/amarok/-/merge_requests/76
Git commit 728878aaf2d81bb4fdbfce2b982ced34f07f5692 by Tuomas Nurmi. Committed on 07/04/2024 at 08:16. Pushed by nurmi into branch 'master'. Fix script console crashing when reopened. When script console is opened for the second time, it crashes. I.e. if enabled, it is opened first time at program startup. If closed, script console will open again when one opens Amarok settings and applies them with Apply or OK, causing also a Segmentation fault in QJSEngine::newQObject(QObject*). This originates from MetaTrackPrototype::init (and next one would come from TrackSetExporter::init), where if (s_wrapper == nullptr) s_wrapper = new MetaTrackPrototypeWrapper( engine ); QJSValue scriptObj = engine->newQObject( s_wrapper ); is called. However, as the MetaTrackPrototypeWrapper is parented to engine on creation, deletion of engine (e.g. when closing the script console) apparently causes s_wrapper to get deleted, too. Or if it isn't parented, it gets probably cleaned away when the QJSEngine shuts down, assumedly because it has been wrapped to QJSEngine with engine->newQObject(). And even if it didn't get deleted, the trackCtor function returns m_engine->newQObject(...), engine being already deleted, so seems that a new instance should be used for each new engine, instead of a static wrapper. There's still another aspect not yet addressed by this, though: On new script console window creation, qRegisterMetaType()'s and QMetaType::registerConverter()'s, that apparently should only be called once, are called again, resulting in such debug output: Type conversion already registered from type Collections::Collection* to type QJSValue Type conversion already registered from type QJSValue to type Collections::Collection* While these don't seem to be dangerous and could easily be safeguarded against by e.g. adding some static s_QMetaTypeInitialized variables for each, there seems to be a catch: the global registerConverters from C++ classes to QJSValues are created with local QJSEngine *engine as parameter, which is then used by toScriptValue() to do the JS Object creation. I'd imagine this fails if the engine used for creation is not the same as the Object's target engine, and crashes if the engine has been deleted since, which seems to happen at at least closing of script window. I haven't yet encountered these errors/crashes, however, and I'm not quite sure when the registerConverters actually get used. I guess one solution could be registering converters to be from e.g. QPair<Meta::TrackPtr,QJSEngine*> to QJSValue>, and forwarding the current QJSEngine* to toScriptValue when doing any conversions. I'm not completely sure if this is the best path anyhow (using QJSEngine::newQMetaObject looks somewhat promising approach, too), but for now, I think it is a right step, and I will probably gain better understanding of the conversions and everything script-related now that I can test the scripting tools a bit more easily as Amarok doesn't crash every time I want to re-open the console. M +1 -1 ChangeLog M +2 -6 src/scripting/scriptengine/exporters/MetaTypeExporter.cpp M +0 -1 src/scripting/scriptengine/exporters/MetaTypeExporter.h M +2 -9 src/scripting/scriptengine/exporters/ScriptableBiasExporter.cpp M +0 -3 src/scripting/scriptengine/exporters/ScriptableBiasExporter.h https://invent.kde.org/multimedia/amarok/-/commit/728878aaf2d81bb4fdbfce2b982ced34f07f5692