Repository navigation
Percussion panel - refinements round 6 - #26108
Conversation
48e4f97 to
321dd54
Compare
cbjeukendrup
left a comment
There was a problem hiding this comment.
Mostly looks good, but a couple of questions:
There was a problem hiding this comment.
I thought about this a lot while working on this fix and found it quite hard to conceive of a situation where code like this would cause problems with undo/redo. Based on your experience was there something in particular you were concerned about here? The general flow boils down to this:
- We load a drumset with undefined
panelRow/panelColumnproperties. - The panel decides where the undefined pads should go - they’ll always be placed chromatically after the last “defined pad”. Nothing else changes about the drumset here.
- We update the score’s drumset with the new
panelRow/panelColumnproperties. This ensures the early return executes insideupdatePadModelsthe next time it's called.
There was a problem hiding this comment.
It sounds like that will probably work fine then, but it is something to keep an eye on. For example, the following scenario might be risky:
- User edits drumset manually -> drumset change is recorded in undo stack
- PercussionPanelModel::setDrumset changes drumset without informing undo stack
- User undoes and redoes -> now the drumset from before step 2 is back, because that was recorded in the undo stack.
However that wouldn't matter much because PercussionPanelModel::setDrumset could just do the same thing again later of course.
Another thing to watch out for is that we don't end up with memory leaks, or pointers to memory that's managed by the undo stack and the undo stack thinks it can be deleted but in reality it's still used. But in this case I don't immediately see how that situation could be produced either.
So let's try it like this, but let's make sure that it is considered during testing.
There was a problem hiding this comment.
It somehow feels inconsistent that this method is in DockPanelView while currentWidgetInFrame is in DockBase, while these two methods are actually counterparts. Maybe you could either bring them closer together, or make setCurrentWidget take a DockPanelView* rather than KDDockWidgets::DockWidgetQuick*.
(Also, the purist in me would say it's questionable that DockPanelView/DockBase, which are primarily an abstraction around KDDockWidgets::DockWidgetQuick, contain methods that manipulate KDDockWidgets::Frame; but changing that is probably not worth the effort. One option would be to solve it by creating methods isCurrentTabInFrame and makeCurrentTabInFrame or something similar.)
There was a problem hiding this comment.
Thanks! I like the sound of isCurrent and makeCurrent - pushed now.
9cdb545 to
f32b7da
Compare
|
Getting a crash on this after editing pads video1136697281.mp4 |
Attempting to open a panel (e.g. Mixer) when it is in another tab will now cause the dock to switch tabs to the requested panel
a61d047 to
bbf3e9a
Compare
|
Well, that was a palaver... I couldn’t repro the crash at all in local builds so I had to investigate this blind. Looks to have been down to a silly mistake in I made another couple of tweaks while I was at it (some small optimisations, and a quick tweak to the enabled status of the "legacy panel" text in percussion preferences).
Rebased because of some VTest stuff - the only changes to the PR since the last review can be found in bbf3e9ab50550f6c69762970dce6299b5d4a41ed. |
There was a problem hiding this comment.
Is it certain that m_padListModel isn't gonna suddenly delete its drumset? Actually, it looks like it does, in its destructor... isn't that a problem?
There was a problem hiding this comment.
Should be fine - m_padListModel is only destroyed when the PercussionPanelModel itself is destroyed (through deleteChildren). There shouldn’t be a situation where the list model has been destroyed but the PercussionPanelModel hasn’t.
There was a problem hiding this comment.
The problem I was thinking of, would be that inst then contains a pointer to deleted memory; but now I see that Instrument::setDrumset makes a copy, so that's fine.
However, when running with Address Sanitizer, I did find another crash: when you click 'Edit layout', then make some edits, and click 'Finish editing', a crash occurs. ASan output:
Click to expand
=================================================================
==49884==ERROR: AddressSanitizer: heap-use-after-free on address 0x628000950100 at pc 0x00010002b218 bp 0x00016fdf09d0 sp 0x00016fdf09c8
READ of size 8 at 0x628000950100 thread T0
#0 0x10002b214 in std::__1::shared_ptr<std::__1::basic_string<char16_t, std::__1::char_traits<char16_t>, std::__1::allocator<char16_t>>>::shared_ptr[abi:ne180100](std::__1::shared_ptr<std::__1::basic_string<char16_t, std::__1::char_traits<char16_t>, std::__1::allocator<char16_t>>> const&) shared_ptr.h:565
#1 0x10002b1a8 in std::__1::shared_ptr<std::__1::basic_string<char16_t, std::__1::char_traits<char16_t>, std::__1::allocator<char16_t>>>::shared_ptr[abi:ne180100](std::__1::shared_ptr<std::__1::basic_string<char16_t, std::__1::char_traits<char16_t>, std::__1::allocator<char16_t>>> const&) shared_ptr.h:565
#2 0x10002b138 in muse::String::String(muse::String const&) string.h:202
#3 0x1000285c4 in muse::String::String(muse::String const&) string.h:202
#4 0x1017e9fe0 in mu::engraving::DrumInstrument::DrumInstrument(mu::engraving::DrumInstrument const&) drumset.h:52
#5 0x1017e9fac in mu::engraving::DrumInstrument::DrumInstrument(mu::engraving::DrumInstrument const&) drumset.h:52
#6 0x1017e9ef8 in mu::engraving::Drumset::Drumset(mu::engraving::Drumset const&) drumset.h:99
#7 0x1017ce3bc in mu::engraving::Drumset::Drumset(mu::engraving::Drumset const&) drumset.h:99
#8 0x104f0a78c in mu::notation::PercussionPanelPadListModel::setDrumset(mu::engraving::Drumset const*) percussionpanelpadlistmodel.cpp:172
#9 0x104f06bac in mu::notation::PercussionPanelModel::setDrumset(mu::engraving::Drumset*) percussionpanelmodel.cpp:313
#10 0x104f08fdc in mu::notation::PercussionPanelModel::setUpConnections()::$_0::operator()(mu::engraving::Drumset*) const percussionpanelmodel.cpp:254
#11 0x104f65b4c in mu::notation::PercussionPanelModel::setUpConnections()::$_1::operator()() const percussionpanelmodel.cpp:273
#12 0x104f6574c in decltype(std::declval<mu::notation::PercussionPanelModel::setUpConnections()::$_1&>()()) std::__1::__invoke[abi:ne180100]<mu::notation::PercussionPanelModel::setUpConnections()::$_1&>(mu::notation::PercussionPanelModel::setUpConnections()::$_1&) invoke.h:344
#13 0x104f65728 in decltype(auto) std::__1::__apply_tuple_impl[abi:ne180100]<mu::notation::PercussionPanelModel::setUpConnections()::$_1&, std::__1::tuple<>>(mu::notation::PercussionPanelModel::setUpConnections()::$_1&, std::__1::tuple<>&&, std::__1::__tuple_indices<>) tuple:1424
#14 0x104f65700 in decltype(auto) std::__1::apply[abi:ne180100]<mu::notation::PercussionPanelModel::setUpConnections()::$_1&, std::__1::tuple<>>(mu::notation::PercussionPanelModel::setUpConnections()::$_1&, std::__1::tuple<>&&) tuple:1428
#15 0x104f65614 in kors::async::Channel<>::ReceiveCall<mu::notation::PercussionPanelModel::setUpConnections()::$_1>::received(kors::async::NotifyData const&) channel.h:102
#16 0x100876ff0 in kors::async::Channel<>::ChannelInvoker::doInvoke(int, void*, kors::async::NotifyData const&) channel.h:148
#17 0x100554d90 in kors::async::AbstractInvoker::invokeCallback(int, kors::async::AbstractInvoker::CallBack const&, kors::async::NotifyData const&) abstractinvoker.cpp:93
#18 0x100553940 in kors::async::AbstractInvoker::invoke(int, kors::async::NotifyData const&) abstractinvoker.cpp:70
#19 0x100874ba8 in kors::async::Channel<>::send() channel.h:54
#20 0x10086e664 in kors::async::Notification::notify() notification.h:36
#21 0x105313d94 in mu::notation::NotationInteraction::notifyAboutNoteInputStateChanged() notationinteraction.cpp:331
#22 0x105667598 in mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2::operator()() const notationinteraction.cpp:203
#23 0x105667528 in decltype(std::declval<mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&>()()) std::__1::__invoke[abi:ne180100]<mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&>(mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&) invoke.h:344
#24 0x105667504 in decltype(auto) std::__1::__apply_tuple_impl[abi:ne180100]<mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&, std::__1::tuple<>>(mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&, std::__1::tuple<>&&, std::__1::__tuple_indices<>) tuple:1424
#25 0x1056674dc in decltype(auto) std::__1::apply[abi:ne180100]<mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&, std::__1::tuple<>>(mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&, std::__1::tuple<>&&) tuple:1428
#26 0x1056673f0 in kors::async::Channel<>::ReceiveCall<mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2>::received(kors::async::NotifyData const&) channel.h:102
#27 0x100876ff0 in kors::async::Channel<>::ChannelInvoker::doInvoke(int, void*, kors::async::NotifyData const&) channel.h:148
#28 0x100554d90 in kors::async::AbstractInvoker::invokeCallback(int, kors::async::AbstractInvoker::CallBack const&, kors::async::NotifyData const&) abstractinvoker.cpp:93
#29 0x100553940 in kors::async::AbstractInvoker::invoke(int, kors::async::NotifyData const&) abstractinvoker.cpp:70
#30 0x100874ba8 in kors::async::Channel<>::send() channel.h:54
#31 0x10086e664 in kors::async::Notification::notify() notification.h:36
#32 0x1057a6d20 in mu::notation::NotationUndoStack::notifyAboutStateChanged() notationundostack.cpp:286
#33 0x1057a9610 in mu::notation::NotationUndoStack::commitChanges() notationundostack.cpp:144
#34 0x104f04ed0 in mu::notation::PercussionPanelModel::finishEditing(bool) percussionpanelmodel.cpp:232
#35 0x105722e24 in mu::notation::PercussionPanelModel::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) moc_percussionpanelmodel.cpp:194
#36 0x1057246c4 in mu::notation::PercussionPanelModel::qt_metacall(QMetaObject::Call, int, void**) moc_percussionpanelmodel.cpp:319
#37 0x118e439e0 in CallMethod(QQmlObjectOrGadget const&, int, QMetaType, int, QMetaType const*, QV4::ExecutionEngine*, QV4::CallData*, QMetaObject::Call)+0x1548 (QtQml:arm64+0x1279e0)
#38 0x118e402cc in CallPrecise(QQmlObjectOrGadget const&, QQmlPropertyData const&, QV4::ExecutionEngine*, QV4::CallData*, QMetaObject::Call)+0x2c4 (QtQml:arm64+0x1242cc)
#39 0x118e3ee78 in QV4::QObjectMethod::callInternal(QV4::Value const*, QV4::Value const*, int) const+0x334 (QtQml:arm64+0x122e78)
#40 0x118e89e88 in QV4::Moth::VME::interpret(QV4::JSTypesStackFrame*, QV4::ExecutionEngine*, char const*)+0x118c (QtQml:arm64+0x16de88)
#41 0x118e88b80 in QV4::Moth::VME::exec(QV4::JSTypesStackFrame*, QV4::ExecutionEngine*)+0x8c (QtQml:arm64+0x16cb80)
#42 0x118e015bc in QV4::Function::call(QV4::Value const*, QV4::Value const*, int, QV4::ExecutionContext const*)+0x160 (QtQml:arm64+0xe55bc)
#43 0x118e012d8 in QV4::Function::call(QV4::Value const*, void**, QMetaType const*, int, QV4::ExecutionContext const*)+0xec (QtQml:arm64+0xe52d8)
#44 0x118f048d0 in QQmlJavaScriptExpression::evaluate(void**, QMetaType const*, int)+0x190 (QtQml:arm64+0x1e88d0)
#45 0x118ec4e18 in QQmlBoundSignalExpression::evaluate(void**)+0x2d8 (QtQml:arm64+0x1a8e18)
#46 0x118ec53ac in QQmlBoundSignal_callback(QQmlNotifierEndpoint*, void**)+0x154 (QtQml:arm64+0x1a93ac)
#47 0x118f22784 in QQmlNotifier::emitNotify(QQmlNotifierEndpoint*, void**)+0x1f4 (QtQml:arm64+0x206784)
#48 0x11abfc08c in void doActivate<false>(QObject*, int, void**)+0x94 (QtCore:arm64+0xd808c)
#49 0x118fa0aac in QQmlVMEMetaObject::metaCall(QObject*, QMetaObject::Call, int, void**)+0x360 (QtQml:arm64+0x284aac)
#50 0x118e43ae0 in CallMethod(QQmlObjectOrGadget const&, int, QMetaType, int, QMetaType const*, QV4::ExecutionEngine*, QV4::CallData*, QMetaObject::Call)+0x1648 (QtQml:arm64+0x127ae0)
#51 0x118e40394 in CallPrecise(QQmlObjectOrGadget const&, QQmlPropertyData const&, QV4::ExecutionEngine*, QV4::CallData*, QMetaObject::Call)+0x38c (QtQml:arm64+0x124394)
#52 0x118e3ee78 in QV4::QObjectMethod::callInternal(QV4::Value const*, QV4::Value const*, int) const+0x334 (QtQml:arm64+0x122e78)
#53 0x118e89e88 in QV4::Moth::VME::interpret(QV4::JSTypesStackFrame*, QV4::ExecutionEngine*, char const*)+0x118c (QtQml:arm64+0x16de88)
#54 0x118e88b80 in QV4::Moth::VME::exec(QV4::JSTypesStackFrame*, QV4::ExecutionEngine*)+0x8c (QtQml:arm64+0x16cb80)
#55 0x118e015bc in QV4::Function::call(QV4::Value const*, QV4::Value const*, int, QV4::ExecutionContext const*)+0x160 (QtQml:arm64+0xe55bc)
#56 0x118e012d8 in QV4::Function::call(QV4::Value const*, void**, QMetaType const*, int, QV4::ExecutionContext const*)+0xec (QtQml:arm64+0xe52d8)
#57 0x118f048d0 in QQmlJavaScriptExpression::evaluate(void**, QMetaType const*, int)+0x190 (QtQml:arm64+0x1e88d0)
#58 0x118ec4e18 in QQmlBoundSignalExpression::evaluate(void**)+0x2d8 (QtQml:arm64+0x1a8e18)
#59 0x118ec53ac in QQmlBoundSignal_callback(QQmlNotifierEndpoint*, void**)+0x154 (QtQml:arm64+0x1a93ac)
#60 0x118f22784 in QQmlNotifier::emitNotify(QQmlNotifierEndpoint*, void**)+0x1f4 (QtQml:arm64+0x206784)
#61 0x11abfc08c in void doActivate<false>(QObject*, int, void**)+0x94 (QtCore:arm64+0xd808c)
#62 0x1187493c0 in QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent*, QQuickItem*, QPointF const&, QQuickMouseAreaPrivate::PropagateType)+0x234 (QtQuick:arm64+0x713c0)
#63 0x1187492a4 in QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent*, QQuickItem*, QPointF const&, QQuickMouseAreaPrivate::PropagateType)+0x118 (QtQuick:arm64+0x712a4)
#64 0x1187492a4 in QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent*, QQuickItem*, QPointF const&, QQuickMouseAreaPrivate::PropagateType)+0x118 (QtQuick:arm64+0x712a4)
#65 0x1187492a4 in QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent*, QQuickItem*, QPointF const&, QQuickMouseAreaPrivate::PropagateType)+0x118 (QtQuick:arm64+0x712a4)
#66 0x1187492a4 in QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent*, QQuickItem*, QPointF const&, QQuickMouseAreaPrivate::PropagateType)+0x118 (QtQuick:arm64+0x712a4)
#67 0x1187492a4 in QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent*, QQuickItem*, QPointF const&, QQuickMouseAreaPrivate::PropagateType)+0x118 (QtQuick:arm64+0x712a4)
#68 0x1187492a4 in QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent*, QQuickItem*, QPointF const&, QQuickMouseAreaPrivate::PropagateType)+0x118 (QtQuick:arm64+0x712a4)
#69 0x1187492a4 in QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent*, QQuickItem*, QPointF const&, QQuickMouseAreaPrivate::PropagateType)+0x118 (QtQuick:arm64+0x712a4)
#70 0x1187492a4 in QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent*, QQuickItem*, QPointF const&, QQuickMouseAreaPrivate::PropagateType)+0x118 (QtQuick:arm64+0x712a4)
#71 0x1187492a4 in QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent*, QQuickItem*, QPointF const&, QQuickMouseAreaPrivate::PropagateType)+0x118 (QtQuick:arm64+0x712a4)
#72 0x1187492a4 in QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent*, QQuickItem*, QPointF const&, QQuickMouseAreaPrivate::PropagateType)+0x118 (QtQuick:arm64+0x712a4)
#73 0x1187492a4 in QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent*, QQuickItem*, QPointF const&, QQuickMouseAreaPrivate::PropagateType)+0x118 (QtQuick:arm64+0x712a4)
#74 0x1187492a4 in QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent*, QQuickItem*, QPointF const&, QQuickMouseAreaPrivate::PropagateType)+0x118 (QtQuick:arm64+0x712a4)
#75 0x118749e78 in QQuickMouseArea::setPressed(Qt::MouseButton, bool, Qt::MouseEventSource)+0x308 (QtQuick:arm64+0x71e78)
#76 0x11874a698 in QQuickMouseArea::mouseReleaseEvent(QMouseEvent*)+0x98 (QtQuick:arm64+0x72698)
#77 0x11872c468 in QQuickItem::event(QEvent*)+0x6c (QtQuick:arm64+0x54468)
#78 0x117a1c6b8 in QApplicationPrivate::notify_helper(QObject*, QEvent*)+0x10c (QtWidgets:arm64+0xc6b8)
#79 0x117a1d8a8 in QApplication::notify(QObject*, QEvent*)+0x1e8 (QtWidgets:arm64+0xd8a8)
#80 0x11abb4f84 in QCoreApplication::notifyInternal2(QObject*, QEvent*)+0x120 (QtCore:arm64+0x90f84)
#81 0x1188716b0 in QQuickDeliveryAgentPrivate::deliverMatchingPointsToItem(QQuickItem*, bool, QPointerEvent*, bool)+0x2cc (QtQuick:arm64+0x1996b0)
#82 0x118870d50 in QQuickDeliveryAgentPrivate::deliverUpdatedPoints(QPointerEvent*)+0x2d4 (QtQuick:arm64+0x198d50)
#83 0x11886b8e0 in QQuickDeliveryAgentPrivate::deliverPointerEvent(QPointerEvent*)+0x9b0 (QtQuick:arm64+0x1938e0)
#84 0x118869a1c in QQuickDeliveryAgentPrivate::handleMouseEvent(QMouseEvent*)+0x12c (QtQuick:arm64+0x191a1c)
#85 0x118869584 in QQuickDeliveryAgent::event(QEvent*)+0x5c (QtQuick:arm64+0x191584)
#86 0x1187ba6c0 in QQuickWindow::event(QEvent*)+0xcf8 (QtQuick:arm64+0xe26c0)
#87 0x117a1c6b8 in QApplicationPrivate::notify_helper(QObject*, QEvent*)+0x10c (QtWidgets:arm64+0xc6b8)
#88 0x117a1d8a8 in QApplication::notify(QObject*, QEvent*)+0x1e8 (QtWidgets:arm64+0xd8a8)
#89 0x11abb4f84 in QCoreApplication::notifyInternal2(QObject*, QEvent*)+0x120 (QtCore:arm64+0x90f84)
#90 0x11a36db80 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*)+0x6a8 (QtGui:arm64+0x79b80)
#91 0x11a3c2194 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)+0x188 (QtGui:arm64+0xce194)
#92 0x11c694ff8 in QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void*)+0xa0 (libqcocoa.dylib:arm64+0x14ff8)
#93 0x189538890 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+0x18 (CoreFoundation:arm64e+0x7d890)
#94 0x189538824 in __CFRunLoopDoSource0+0xac (CoreFoundation:arm64e+0x7d824)
#95 0x189538588 in __CFRunLoopDoSources0+0xf0 (CoreFoundation:arm64e+0x7d588)
#96 0x189537124 in __CFRunLoopRun+0x344 (CoreFoundation:arm64e+0x7c124)
#97 0x189536720 in CFRunLoopRunSpecific+0x248 (CoreFoundation:arm64e+0x7b720)
#98 0x194a8e52c in RunCurrentEventLoopInMode+0x120 (HIToolbox:arm64e+0x10b52c)
#99 0x194a94178 in ReceiveNextEventCommon+0xd4 (HIToolbox:arm64e+0x111178)
#100 0x194a94504 in _BlockUntilNextEventMatchingListInModeWithFilter+0x48 (HIToolbox:arm64e+0x111504)
#101 0x18d0a1030 in _DPSNextEvent+0x290 (AppKit:arm64e+0x3b030)
#102 0x18da052d0 in -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]+0x2ac (AppKit:arm64e+0x99f2d0)
#103 0x18d09405c in -[NSApplication run]+0x1dc (AppKit:arm64e+0x2e05c)
#104 0x11c693df4 in QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)+0x648 (libqcocoa.dylib:arm64+0x13df4)
#105 0x11abbde44 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)+0x1ec (QtCore:arm64+0x99e44)
#106 0x11abb5648 in QCoreApplication::exec()+0x7c (QtCore:arm64+0x91648)
#107 0x10000fd14 in main main.cpp:206
#108 0x1890d0270 (<unknown module>)
0x628000950100 is located 0 bytes inside of 14336-byte region [0x628000950100,0x628000953900)
freed by thread T0 here:
#0 0x1192702d4 in _ZdlPv+0x74 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x642d4)
#1 0x101868c70 in mu::engraving::Instrument::setDrumset(mu::engraving::Drumset const*) instrument.cpp:908
#2 0x104f06d0c in mu::notation::PercussionPanelModel::setDrumset(mu::engraving::Drumset*) percussionpanelmodel.cpp:322
#3 0x104f04018 in mu::notation::PercussionPanelModel::finishEditing(bool) percussionpanelmodel.cpp:192
#4 0x104f08fc8 in mu::notation::PercussionPanelModel::setUpConnections()::$_0::operator()(mu::engraving::Drumset*) const percussionpanelmodel.cpp:251
#5 0x104f65b4c in mu::notation::PercussionPanelModel::setUpConnections()::$_1::operator()() const percussionpanelmodel.cpp:273
#6 0x104f6574c in decltype(std::declval<mu::notation::PercussionPanelModel::setUpConnections()::$_1&>()()) std::__1::__invoke[abi:ne180100]<mu::notation::PercussionPanelModel::setUpConnections()::$_1&>(mu::notation::PercussionPanelModel::setUpConnections()::$_1&) invoke.h:344
#7 0x104f65728 in decltype(auto) std::__1::__apply_tuple_impl[abi:ne180100]<mu::notation::PercussionPanelModel::setUpConnections()::$_1&, std::__1::tuple<>>(mu::notation::PercussionPanelModel::setUpConnections()::$_1&, std::__1::tuple<>&&, std::__1::__tuple_indices<>) tuple:1424
#8 0x104f65700 in decltype(auto) std::__1::apply[abi:ne180100]<mu::notation::PercussionPanelModel::setUpConnections()::$_1&, std::__1::tuple<>>(mu::notation::PercussionPanelModel::setUpConnections()::$_1&, std::__1::tuple<>&&) tuple:1428
#9 0x104f65614 in kors::async::Channel<>::ReceiveCall<mu::notation::PercussionPanelModel::setUpConnections()::$_1>::received(kors::async::NotifyData const&) channel.h:102
#10 0x100876ff0 in kors::async::Channel<>::ChannelInvoker::doInvoke(int, void*, kors::async::NotifyData const&) channel.h:148
#11 0x100554d90 in kors::async::AbstractInvoker::invokeCallback(int, kors::async::AbstractInvoker::CallBack const&, kors::async::NotifyData const&) abstractinvoker.cpp:93
#12 0x100553940 in kors::async::AbstractInvoker::invoke(int, kors::async::NotifyData const&) abstractinvoker.cpp:70
#13 0x100874ba8 in kors::async::Channel<>::send() channel.h:54
#14 0x10086e664 in kors::async::Notification::notify() notification.h:36
#15 0x105313d94 in mu::notation::NotationInteraction::notifyAboutNoteInputStateChanged() notationinteraction.cpp:331
#16 0x105667598 in mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2::operator()() const notationinteraction.cpp:203
#17 0x105667528 in decltype(std::declval<mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&>()()) std::__1::__invoke[abi:ne180100]<mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&>(mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&) invoke.h:344
#18 0x105667504 in decltype(auto) std::__1::__apply_tuple_impl[abi:ne180100]<mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&, std::__1::tuple<>>(mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&, std::__1::tuple<>&&, std::__1::__tuple_indices<>) tuple:1424
#19 0x1056674dc in decltype(auto) std::__1::apply[abi:ne180100]<mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&, std::__1::tuple<>>(mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2&, std::__1::tuple<>&&) tuple:1428
#20 0x1056673f0 in kors::async::Channel<>::ReceiveCall<mu::notation::NotationInteraction::NotationInteraction(mu::notation::Notation*, std::__1::shared_ptr<mu::notation::INotationUndoStack>)::$_2>::received(kors::async::NotifyData const&) channel.h:102
#21 0x100876ff0 in kors::async::Channel<>::ChannelInvoker::doInvoke(int, void*, kors::async::NotifyData const&) channel.h:148
#22 0x100554d90 in kors::async::AbstractInvoker::invokeCallback(int, kors::async::AbstractInvoker::CallBack const&, kors::async::NotifyData const&) abstractinvoker.cpp:93
#23 0x100553940 in kors::async::AbstractInvoker::invoke(int, kors::async::NotifyData const&) abstractinvoker.cpp:70
#24 0x100874ba8 in kors::async::Channel<>::send() channel.h:54
#25 0x10086e664 in kors::async::Notification::notify() notification.h:36
#26 0x1057a6d20 in mu::notation::NotationUndoStack::notifyAboutStateChanged() notationundostack.cpp:286
#27 0x1057a9610 in mu::notation::NotationUndoStack::commitChanges() notationundostack.cpp:144
#28 0x104f04ed0 in mu::notation::PercussionPanelModel::finishEditing(bool) percussionpanelmodel.cpp:232
#29 0x105722e24 in mu::notation::PercussionPanelModel::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) moc_percussionpanelmodel.cpp:194
previously allocated by thread T0 here:
#0 0x11926fe94 in _Znwm+0x74 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x63e94)
#1 0x101868cf4 in mu::engraving::Instrument::setDrumset(mu::engraving::Drumset const*) instrument.cpp:911
#2 0x10242d48c in mu::engraving::ChangeDrumset::flip(mu::engraving::EditData*) undo.cpp:3040
#3 0x1023f2d10 in mu::engraving::UndoCommand::redo(mu::engraving::EditData*) undo.cpp:209
#4 0x1023f6990 in mu::engraving::UndoStack::pushAndPerform(mu::engraving::UndoCommand*, mu::engraving::EditData*) undo.cpp:369
#5 0x101dd3b10 in mu::engraving::Score::undo(mu::engraving::UndoCommand*, mu::engraving::EditData*) const score.cpp:4351
#6 0x104f04e40 in mu::notation::PercussionPanelModel::finishEditing(bool) percussionpanelmodel.cpp:231
#7 0x105722e24 in mu::notation::PercussionPanelModel::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) moc_percussionpanelmodel.cpp:194
#8 0x1057246c4 in mu::notation::PercussionPanelModel::qt_metacall(QMetaObject::Call, int, void**) moc_percussionpanelmodel.cpp:319
#9 0x118e439e0 in CallMethod(QQmlObjectOrGadget const&, int, QMetaType, int, QMetaType const*, QV4::ExecutionEngine*, QV4::CallData*, QMetaObject::Call)+0x1548 (QtQml:arm64+0x1279e0)
#10 0x118e402cc in CallPrecise(QQmlObjectOrGadget const&, QQmlPropertyData const&, QV4::ExecutionEngine*, QV4::CallData*, QMetaObject::Call)+0x2c4 (QtQml:arm64+0x1242cc)
#11 0x118e3ee78 in QV4::QObjectMethod::callInternal(QV4::Value const*, QV4::Value const*, int) const+0x334 (QtQml:arm64+0x122e78)
#12 0x118e89e88 in QV4::Moth::VME::interpret(QV4::JSTypesStackFrame*, QV4::ExecutionEngine*, char const*)+0x118c (QtQml:arm64+0x16de88)
#13 0x118e88b80 in QV4::Moth::VME::exec(QV4::JSTypesStackFrame*, QV4::ExecutionEngine*)+0x8c (QtQml:arm64+0x16cb80)
#14 0x118e015bc in QV4::Function::call(QV4::Value const*, QV4::Value const*, int, QV4::ExecutionContext const*)+0x160 (QtQml:arm64+0xe55bc)
#15 0x118e012d8 in QV4::Function::call(QV4::Value const*, void**, QMetaType const*, int, QV4::ExecutionContext const*)+0xec (QtQml:arm64+0xe52d8)
#16 0x118f048d0 in QQmlJavaScriptExpression::evaluate(void**, QMetaType const*, int)+0x190 (QtQml:arm64+0x1e88d0)
#17 0x118ec4e18 in QQmlBoundSignalExpression::evaluate(void**)+0x2d8 (QtQml:arm64+0x1a8e18)
#18 0x118ec53ac in QQmlBoundSignal_callback(QQmlNotifierEndpoint*, void**)+0x154 (QtQml:arm64+0x1a93ac)
#19 0x118f22784 in QQmlNotifier::emitNotify(QQmlNotifierEndpoint*, void**)+0x1f4 (QtQml:arm64+0x206784)
#20 0x11abfc08c in void doActivate<false>(QObject*, int, void**)+0x94 (QtCore:arm64+0xd808c)
#21 0x118fa0aac in QQmlVMEMetaObject::metaCall(QObject*, QMetaObject::Call, int, void**)+0x360 (QtQml:arm64+0x284aac)
#22 0x118e43ae0 in CallMethod(QQmlObjectOrGadget const&, int, QMetaType, int, QMetaType const*, QV4::ExecutionEngine*, QV4::CallData*, QMetaObject::Call)+0x1648 (QtQml:arm64+0x127ae0)
#23 0x118e40394 in CallPrecise(QQmlObjectOrGadget const&, QQmlPropertyData const&, QV4::ExecutionEngine*, QV4::CallData*, QMetaObject::Call)+0x38c (QtQml:arm64+0x124394)
#24 0x118e3ee78 in QV4::QObjectMethod::callInternal(QV4::Value const*, QV4::Value const*, int) const+0x334 (QtQml:arm64+0x122e78)
#25 0x118e89e88 in QV4::Moth::VME::interpret(QV4::JSTypesStackFrame*, QV4::ExecutionEngine*, char const*)+0x118c (QtQml:arm64+0x16de88)
#26 0x118e88b80 in QV4::Moth::VME::exec(QV4::JSTypesStackFrame*, QV4::ExecutionEngine*)+0x8c (QtQml:arm64+0x16cb80)
#27 0x118e015bc in QV4::Function::call(QV4::Value const*, QV4::Value const*, int, QV4::ExecutionContext const*)+0x160 (QtQml:arm64+0xe55bc)
#28 0x118e012d8 in QV4::Function::call(QV4::Value const*, void**, QMetaType const*, int, QV4::ExecutionContext const*)+0xec (QtQml:arm64+0xe52d8)
#29 0x118f048d0 in QQmlJavaScriptExpression::evaluate(void**, QMetaType const*, int)+0x190 (QtQml:arm64+0x1e88d0)
SUMMARY: AddressSanitizer: heap-use-after-free shared_ptr.h:565 in std::__1::shared_ptr<std::__1::basic_string<char16_t, std::__1::char_traits<char16_t>, std::__1::allocator<char16_t>>>::shared_ptr[abi:ne180100](std::__1::shared_ptr<std::__1::basic_string<char16_t, std::__1::char_traits<char16_t>, std::__1::allocator<char16_t>>> const&)
Shadow bytes around the buggy address:
0x62800094fe80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x62800094ff00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x62800094ff80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x628000950000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x628000950080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x628000950100:[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x628000950180: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x628000950200: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x628000950280: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x628000950300: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x628000950380: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==49884==ABORTINGThere was a problem hiding this comment.
Hmm - again I can’t repro this locally (with or without ASAN) but it definitely looks like you've found a legitimate problem here. From the output you’ve sent this is what I've gathered (I'll call the problematic address addressA):
finishEditing(note that the first thing this does is take us out ofEDIT_LAYOUTmode).-
Call the
ChangeDrumsetUndoCommand -
Instrument::setDrumsetallocatesaddressA
Then (still in finishEditing):
-
commitChanges/notifyAboutStateChanged finishEditinggets another call fromupdatePadModels, this time discarding changes (strange that this happens at all because we shouldn't be inEDIT_LAYOUTmode anymore).- Inside the
discardChangesconditionalsetDrumsetcallsInstrument::setDrumsetwhich deallocatesaddressA
Going back to updatePadModels, after the EDIT_LAYOUT conditional:
-
setDrumset(drumsetstill points toaddressA, which was freed by the second call tofinishEditing) - Kaboom
Why finishEditing gets that second call is a bit confusing to me, but the core fix looks pretty simple. In updatePadModels we just need to put the setDrumset call inside the else of m_currentPanelMode == PanelMode::Mode::EDIT_LAYOUT so that we don't call it a second time with garbage data.
I've pushed that now - let me know if this looks any better.
There was a problem hiding this comment.
It seems fine now. The code looks okay, and I can't make it crash anymore :)
bbf3e9a to
361506c
Compare
|
Tested on MacOS 15, Windows 11, Ubuntu 22.04.3. Approved |
Just a small round of refinements this time:
PercussionPanelModel::setDrumsetgives more details (7572404f7bc03e3ccb2f0f943639c3c7c5670aad)Resolves #26009