musescore / MuseScore

MuseScore is an open source and free music notation software. For support, contribution, bug reports, visit MuseScore.org. Fork and make pull requests!
https://musescore.org
Other
12.38k stars 2.68k forks source link

Crash undo-ing adding note to MM rest with particular score #23043

Closed wizofaus closed 5 months ago

wizofaus commented 6 months ago

Issue type

Crash or freeze

Bug description

Not sure why this score is unusual, but if I add a note to the first MM rest, then undo, it reliably crashes

Steps to reproduce

  1. Load attached score
  2. Add a note where first MM rest is (NB it will not redraw correctly in linear view, this is a separate issue I've been looking at)
  3. Undo

Alternatively:

  1. Create any new score (just a single instrument is fine)
  2. Delete all but 2 measures
  3. Turn on MM rests (score should show as a single MM rest with a "2" above it)
  4. Save, close, reopen
  5. Add a note
  6. Undo & crash

Screenshots/Screen recordings

mmrest.mscz.zip

(remove .zip extension, or unzip and load .mscx)

MuseScore Version

5.4

Regression

I don't know

Operating system

Windows 11

Additional context

MuseScore4.exe!std::vector<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>,std::allocator<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>>>::_Tidy() Line 2053C++ [Inline Frame] MuseScore4.exe!std::vector<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>,std::allocator<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>>>::{dtor}() Line 765C++ [Inline Frame] MuseScore4.exe!std::_Default_allocator_traits<std::allocator<std::_Tree_node<std::pair<int64 const ,std::vector<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>,std::allocator<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>>>>,void *>>>::destroy(std::allocator<std::_Tree_node<std::pair<int64 const ,std::vector<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>,std::allocator<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>>>>,void >> & _Ptr, std::pair<__int64 const ,std::vector<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>,std::allocator<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>>>> const) Line 736C++ [Inline Frame] MuseScore4.exe!std::_Tree_node<std::pair<int64 const ,std::vector<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>,std::allocator<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>>>>,void >::_Freenode(std::allocator<std::_Tree_node<std::pair<__int64 const ,std::vector<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>,std::allocator<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>>>>,void >> &) Line 381C++ [Inline Frame] MuseScore4.exe!std::_Tree<std::_Tmap_traits<int64,std::vector<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>,std::allocator<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>>>,std::less<__int64>,std::allocator<std::pair<int64 const ,std::vector<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>,std::allocator<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>>>>>,0>>::_Erase_unchecked(std::_Tree_unchecked_const_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<__int64 const ,std::vector<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>,std::allocator<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>>>>>>,std::_Iterator_base0>) Line 1281C++ [Inline Frame] MuseScore4.exe!std::_Tree<std::_Tmap_traits<int64,std::vector<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>,std::allocator<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>>>,std::less<__int64>,std::allocator<std::pair<int64 const ,std::vector<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>,std::allocator<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>>>>>,0>>::erase(std::_Tree_const_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<int64 const ,std::vector<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>,std::allocator<std::variant<muse::mpe::NoteEvent,muse::mpe::RestEvent>>>>>>>) Line 1326C++ MuseScore4.exe!mu::engraving::PlaybackModel::removeTrackEvents(const mu::engraving::InstrumentTrackId & trackId, const int64 timestampFrom, const int64 timestampTo) Line 823C++ MuseScore4.exe!mu::engraving::PlaybackModel::removeEventsFromRange(const unsigned int64 trackFrom, const unsigned int64 trackTo, const int64 timestampFrom, const int64 timestampTo) Line 688C++ MuseScore4.exe!mu::engraving::PlaybackModel::clearExpiredEvents(const int tickFrom, const int tickTo, const unsigned int64 trackFrom, const unsigned int64 trackTo) Line 758C++ MuseScore4.exe!mu::engraving::PlaybackModel::load::l2::::operator()(const mu::engraving::ScoreChangesRange & range) Line 88C++ [Inline Frame] MuseScore4.exe!std::invoke(mu::engraving::PlaybackModel::load::__l2:: &) Line 1739C++ [Inline Frame] MuseScore4.exe!std::_Apply_impl(mu::engraving::PlaybackModel::load::l2:: &) Line 1077C++ [Inline Frame] MuseScore4.exe!std::apply(mu::engraving::PlaybackModel::load::__l2:: &) Line 1088C++ MuseScore4.exe!kors::async::Channel::ReceiveCall<mu::engraving::PlaybackModel::load'::2'::,mu::engraving::ScoreChangesRange>::received(const kors::async::NotifyData & d) Line 102C++ MuseScore4.exe!kors::async::AbstractInvoker::invokeCallback(int type, const kors::async::AbstractInvoker::CallBack & c, const kors::async::NotifyData & data) Line 91C++ MuseScore4.exe!kors::async::AbstractInvoker::invoke(int type, const kors::async::NotifyData & data) Line 68C++ MuseScore4.exe!kors::async::Channel::send(const mu::engraving::ScoreChangesRange & ) Line 54C++ MuseScore4.exe!mu::engraving::Score::undoRedo(bool undo, mu::engraving::EditData ed) Line 386C++ MuseScore4.exe!mu::notation::NotationUndoStack::undo(mu::engraving::EditData editData) Line 55C++ [External Code] [Inline Frame] MuseScore4.exe!std::_Func_class<void,std::string const &,muse::actions::ActionData const &>::operator()(const std::string &) Line 951C++ MuseScore4.exe!muse::actions::ActionsDispatcher::dispatch(const std::string & actionCode, const muse::actions::ActionData & data) Line 57C++ MuseScore4.exe!muse::shortcuts::ShortcutsController::activate(const std::string & sequence) Line 44C++ MuseScore4.exe!muse::shortcuts::ShortcutsInstanceModel::doActivate(const QString & key) Line 83C++ MuseScore4.exe!muse::shortcuts::ShortcutsInstanceModel::qt_metacall(QMetaObject::Call _c, int _id, void _a) Line 170C++

bkunda commented 6 months ago

@zacjansheski pls investigate

zacjansheski commented 6 months ago

This is reproducible from scratch.

  1. Write a score with mmrests
  2. Save and re-open
  3. Add a note to mmrest
  4. Undo
  5. Crash

https://github.com/musescore/MuseScore/assets/69917893/5eee952b-d72d-45c2-9a9f-e49e5b0d40bc

Crash report

MMRestCrash.zip

wizofaus commented 6 months ago

The crash happens in page view too. I haven't tested re-saving the score in page view though.

zacjansheski commented 6 months ago

Yeah, sorry, doesn't have to do with continuous view

wizofaus commented 5 months ago

Happy to take this on seeing as I found it!

bkunda commented 5 months ago

Thanks @wizofaus. Please feel free to!

wizofaus commented 5 months ago

Those repro steps aren't quite sufficient, it seems to only relate to MM rests of 2 measures. Have updated original report to include.

Jojo-Schmitz commented 5 months ago

Seems to be another variant of #23050. Esp. the fix fort this fixes that also