Bug 472469 - Copying result of mathematical expression often crashes KRunner
Summary: Copying result of mathematical expression often crashes KRunner
Status: RESOLVED FIXED
Alias: None
Product: krunner
Classification: Plasma
Component: calculator (other bugs)
Version First Reported In: master
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: Alexander Lohnau
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2023-07-21 15:55 UTC by Nate Graham
Modified: 2023-07-21 17:58 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nate Graham 2023-07-21 15:55:19 UTC
STEPS TO REPRODUCE
1. Open KRunner
2. Type out "5086-16.64-52.92" (don't copy and paste it; type it out)
3. Click the "copy" button on the list item for the result


OBSERVED RESULT
The result is not copied and KRunner often crashes . It's not 100%, but with those steps, it happens about 50% for me. Backtrace:

#0  __pthread_kill_implementation
    (threadid=<optimized out>, signo=signo@entry=11, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007f29526b08b3 in __pthread_kill_internal (signo=11, threadid=<optimized out>)
    at pthread_kill.c:78
#2  0x00007f295265fabe in __GI_raise (sig=11) at ../sysdeps/posix/raise.c:26
#3  0x00007f2955964916 in KCrash::defaultCrashHandler(int) (sig=11)
    at /home/nate/kde/src/kcrash/src/kcrash.cpp:616
#4  0x00007f295265fb70 in <signal handler called> () at /lib64/libc.so.6
#5  __pthread_kill_implementation
    (threadid=<optimized out>, signo=signo@entry=11, no_tid=no_tid@entry=0) at pthread_kill.c:44
#6  0x00007f29526b08b3 in __pthread_kill_internal (signo=11, threadid=<optimized out>)
    at pthread_kill.c:78
#7  0x00007f295265fabe in __GI_raise (sig=11) at ../sysdeps/posix/raise.c:26
#8  0x00007f295265fb70 in <signal handler called> () at /lib64/libc.so.6
#9  0x00007f29526ab1d7 in __futex_abstimed_wait_common64
    (private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x228cbd0)
    at futex-internal.c:57
#10 __futex_abstimed_wait_common
    (futex_word=futex_word@entry=0x228cbd0, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0, cancel=cancel@entry=true) at futex-internal.c:87
#11 0x00007f29526ab25f in __GI___futex_abstimed_wait_cancelable64
    (futex_word=futex_word@entry=0x228cbd0, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0) at futex-internal.c:139
#12 0x00007f29526adb79 in __pthread_cond_wait_common
    (abstime=0x0, clockid=0, mutex=<optimized out>, cond=0x228cba8) at pthread_cond_wait.c:503
#13 ___pthread_cond_wait (cond=0x228cba8, mutex=<optimized out>) at pthread_cond_wait.c:618
#14 0x00007f2952f0b1ab in QWaitConditionPrivate::wait(QDeadlineTimer) (deadline=..., this=0x228cb80)
    at /usr/src/debug/qt6-qtbase-6.5.1-1.fc38.x86_64/src/corelib/thread/qwaitcondition_unix.cpp:87
#15 QWaitCondition::wait(QMutex*, QDeadlineTimer)
    (this=<optimized out>, mutex=0x235f7b8, deadline=...)
    at /usr/src/debug/qt6-qtbase-6.5.1-1.fc38.x86_64/src/corelib/thread/qwaitcondition_unix.cpp:160
#16 0x00007f29554c53ab in QSGThreadedRenderLoop::handleObscurity(QSGThreadedRenderLoop::Window*)
    (this=this@entry=0x1cf6fd0, w=0x1fd5290)
    at /usr/src/debug/qt6-qtdeclarative-6.5.1-1.fc38.x86_64/src/quick/scenegraph/qsgthreadedrenderloop.cpp:1323
#17 0x00007f29554c6176 in QSGThreadedRenderLoop::hide(QQuickWindow*)
    (this=0x1cf6fd0, window=0x7ffe77663160)
    at /usr/src/debug/qt6-qtdeclarative-6.5.1-1.fc38.x86_64/src/quick/scenegraph/qsgthreadedrenderloop.cpp:1116
#18 0x00007f2953660438 in QWindow::event(QEvent*) (this=0x7ffe77663160, ev=0x7ffe7765d210)
    at /usr/src/debug/qt6-qtbase-6.5.1-1.fc38.x86_64/src/gui/kernel/qwindow.cpp:2523
#19 0x00007f29541c0b08 in QApplicationPrivate::notify_helper(QObject*, QEvent*)
    (this=<optimized out>, receiver=0x7ffe77663160, e=0x7ffe7765d210)
    at /usr/src/debug/qt6-qtbase-6.5.1-1.fc38.x86_64/src/widgets/kernel/qapplication.cpp:3287
#20 0x00007f2952d7c308 in QCoreApplication::notifyInternal2(QObject*, QEvent*)
    (receiver=0x7ffe77663160, event=0x7ffe7765d210)
    at /usr/src/debug/qt6-qtbase-6.5.1-1.fc38.x86_64/src/corelib/kernel/qcoreapplication.cpp:1115
--Type <RET> for more, q to quit, c to continue without paging--c
#21 0x00007f2952d7c50d in QCoreApplication::sendEvent(QObject*, QEvent*)
    (receiver=<optimized out>, event=<optimized out>)
    at /usr/src/debug/qt6-qtbase-6.5.1-1.fc38.x86_64/src/corelib/kernel/qcoreapplication.cpp:1533
#22 0x00007f295365d721 in QWindowPrivate::setVisible(bool) (visible=false, this=<optimized out>)
    at /usr/src/debug/qt6-qtbase-6.5.1-1.fc38.x86_64/src/gui/kernel/qwindow.cpp:397
#23 QWindow::setVisible(bool) (this=<optimized out>, visible=false)
    at /usr/src/debug/qt6-qtbase-6.5.1-1.fc38.x86_64/src/gui/kernel/qwindow.cpp:651
#24 0x00007f2953660a0a in QWindow::qt_metacall(QMetaObject::Call, int, void**)
    (this=this@entry=0x7ffe77663160, _c=_c@entry=QMetaObject::WriteProperty, _id=11, _a=_a@entry=0x7ffe7765d350)
    at /usr/src/debug/qt6-qtbase-6.5.1-1.fc38.x86_64/redhat-linux-build/src/gui/Gui_autogen/include/moc_qwindow.cpp:1097
#25 0x00007f29552e8ecd in QQuickWindow::qt_metacall(QMetaObject::Call, int, void**)
    (this=this@entry=0x7ffe77663160, _c=_c@entry=QMetaObject::WriteProperty, _id=<optimized out>, _a=_a@entry=0x7ffe7765d350)
    at /usr/src/debug/qt6-qtdeclarative-6.5.1-1.fc38.x86_64/redhat-linux-build/src/quick/Quick_autogen/include/moc_qquickwindow.cpp:800
#26 0x00007f2955e7fe45 in PlasmaQuick::PlasmaWindow::qt_metacall(QMetaObject::Call, int, void**)
    (this=this@entry=0x7ffe77663160, _c=_c@entry=QMetaObject::WriteProperty, _id=<optimized out>, _a=_a@entry=0x7ffe7765d350)
    at /home/nate/kde/build6/plasma-framework/src/plasmaquick/KF6PlasmaQuick_autogen/include/moc_plasmawindow.cpp:189
#27 0x00000000004092e5 in View::qt_metacall(QMetaObject::Call, int, void**)
    (this=0x7ffe77663160, _c=QMetaObject::WriteProperty, _id=<optimized out>, _a=0x7ffe7765d350)
    at /home/nate/kde/build6/plasma-workspace/krunner/krunner_autogen/EWIEGA46WW/moc_view.cpp:376
#28 0x00007f2954d0da6d in QQmlPropertyData::doMetacall<(QMetaObject::Call)2>(QObject*, int, void**) const
    (this=<optimized out>, argv=0x7ffe7765d350, idx=<optimized out>, object=0x411aa0 <QtPrivate::QMetaTypeInterfaceWrapper<bool>::metaType@Qt_6>)
    at /usr/src/debug/qt6-qtdeclarative-6.5.1-1.fc38.x86_64/redhat-linux-build/include/QtQml/6.5.1/QtQml/private/../../../../../../src/qml/qml/qqmlpropertydata_p.h:323
#29 QQmlPropertyData::doMetacall<(QMetaObject::Call)2>(QObject*, int, void**) const
    (this=0x1d5cd00, argv=0x7ffe7765d350, idx=<optimized out>, object=0x411aa0 <QtPrivate::QMetaTypeInterfaceWrapper<bool>::metaType@Qt_6>)
    at /usr/src/debug/qt6-qtdeclarative-6.5.1-1.fc38.x86_64/redhat-linux-build/include/QtQml/6.5.1/QtQml/private/../../../../../../src/qml/qml/qqmlpropertydata_p.h:318
#30 QQmlPropertyData::writeProperty(QObject*, void*, QFlags<QQmlPropertyData::WriteFlag>) const
    (this=this@entry=0x1d5cd00, target=target@entry=0x7ffe77663160, value=<optimized out>, flags=..., 
    flags@entry=...)
    at /usr/src/debug/qt6-qtdeclarative-6.5.1-1.fc38.x86_64/redhat-linux-build/include/QtQml/6.5.1/QtQml/private/../../../../../../src/qml/qml/qqmlpropertydata_p.h:341
#31 0x00007f2954dcc309 in QQmlPropertyPrivate::write(QObject*, QQmlPropertyData const&, QVariant const&, QQmlRefPointer<QQmlContextData> const&, QFlags<QQmlPropertyData::WriteFlag>)
    (object=object@entry=0x7ffe77663160, property=..., value=..., context=..., flags=..., 
    flags@entry=...)
    at /usr/src/debug/qt6-qtdeclarative-6.5.1-1.fc38.x86_64/src/qml/qml/qqmlproperty.cpp:1493
#32 0x00007f2954c5adb5 in QV4::QObjectWrapper::setProperty(QV4::ExecutionEngine*, QObject*, QQmlPropertyData const*, QV4::Value const&)
    (engine=engine@entry=0x1f4cc40, object=object@entry=0x7ffe77663160, property=0x1d5cd00, value=...)
    at /usr/include/qt6/QtCore/qflags.h:73
#33 0x00007f2954c5b5a6 in QV4::QObjectWrapper::setQmlProperty(QV4::ExecutionEngine*, QQmlRefPointer<QQmlContextData> const&, QObject*, QV4::String*, QFlags<QV4::QObjectWrapper::Flag>, QV4::Value const&)
    (engine=engine@entry=0x1f4cc40, qmlContext=..., object=0x7ffe77663160, name=<optimized out>, flags=flags@entry=..., value=...)
    at /usr/src/debug/qt6-qtdeclarative-6.5.1-1.fc38.x86_64/src/qml/jsruntime/qv4qobjectwrapper.cpp:464
#34 0x00007f2954c5b786 in QV4::QObjectWrapper::virtualPut(QV4::Managed*, QV4::PropertyKey, QV4::Value const&, QV4::Value*) (m=0x7f2938389700, id=..., value=..., receiver=0x7f2938389700)
    at /usr/src/debug/qt6-qtdeclarative-6.5.1-1.fc38.x86_64/src/qml/jsruntime/qv4qobjectwrapper.cpp:833
#35 0x00007f2954c27cdd in QV4::Object::put(QV4::StringOrSymbol*, QV4::Value const&, QV4::Value*)
    (receiver=<optimized out>, v=..., name=<optimized out>, this=<optimized out>)
    at /usr/src/debug/qt6-qtdeclarative-6.5.1-1.fc38.x86_64/redhat-linux-build/include/QtQml/6.5.1/QtQml/private/../../../../../../src/qml/jsruntime/qv4string_p.h:140
#36 QV4::Lookup::setterFallback(QV4::Lookup*, QV4::ExecutionEngine*, QV4::Value&, QV4::Value const&)
    (l=<optimized out>, engine=0x1f4cc40, object=<optimized out>, value=...)
    at /usr/src/debug/qt6-qtdeclarative-6.5.1-1.fc38.x86_64/src/qml/jsruntime/qv4lookup.cpp:559
#37 0x00007f292405cec9 in  ()
#38 0x00007ffe7765d960 in  ()
#39 0x00007f2954fcd33c in QV4::ExecutionEngine::s_maxCallDepth () at /lib64/libQt6Qml.so.6
#40 0x0000000000000000 in  ()
Comment 1 Alexander Lohnau 2023-07-21 16:03:30 UTC
Yeah, there seems to a bit of unsafe code. I'll look into it.
Comment 2 Bug Janitor Service 2023-07-21 16:16:16 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/3091
Comment 3 Alexander Lohnau 2023-07-21 17:58:53 UTC
Git commit 0dfb6cbfab067b77746ccc9a6edf07434759646e by Alexander Lohnau.
Committed on 21/07/2023 at 17:58.
Pushed by alex into branch 'master'.

runners/calculator: Do not call QObject that lives in another thread

Run is called in the main thread, meaning we should only access the
match and context. Meaning we should not get the text copied in the
engine, but rather read the match text and copy it directly to the
clipboard.

The only difference might a change in the delimiters, but now we copy
the text that the user sees. IMHO that is the best approach anyway.

M  +3    -1    runners/calculator/calculatorrunner.cpp
M  +0    -7    runners/calculator/qalculate_engine.cpp
M  +0    -2    runners/calculator/qalculate_engine.h

https://invent.kde.org/plasma/plasma-workspace/-/commit/0dfb6cbfab067b77746ccc9a6edf07434759646e