Crash on deleting time signatures in front of multimeasure rests

• Jan 12, 2022 - 18:22
Reported version
3.6
Type
Functional
Frequency
Once
Severity
S2 - Critical
Reproducibility
Always
Status
closed
Regression
No
Workaround
Yes
Project

Open attached file
Select any measure
remove measure (ctrl + Del on Windows)
Program crashes

OR

Select time signature on measure 52 (the first 11/8 measure)
delete it
undo
Program crashes

Attachment Size
crash.mscz 9.42 KB

Comments

Status active needs info

No crash for me with either of those operations.

The score creation date is 2020-05-02. What version of MuseScore and what operating system?

In reply to by SteveBlower

That does fix the previous the previous error, but still getting a similar error:
trying to delete the 4/4 time signature in measure 11 still causes a crash.

FYI this and the previous example come from the same original file; I was just trying to figure out where the cause was by removing extra music so I could keep working.

Attachment Size
crash2.mscz 65.58 KB
Title Crash on delete measure Crash on delete time signature
Status needs info active

OK, I can reproduce that crash

Stack trace:

1 Ms::MeasureBase::setPrev measurebase.h 90 0xf13c34
2 Ms::Score::rewriteMeasures edit.cpp 548 0x981dc3
3 Ms::Score::rewriteMeasures edit.cpp 618 0x98241b
4 Ms::Score::cmdRemoveTimeSig edit.cpp 944 0x9843e7
5 Ms::Score::deleteItem edit.cpp 1681 0x988d85
6 Ms::Score::cmdDeleteSelection edit.cpp 2538 0x98dd6d
7 Ms::Score::::operator()(Ms::Score *, Ms::EditData &) const cmd.cpp 4300 0x54b238
8 std::_Function_handler>::_M_invoke(const std::_Any_data &, Ms::Score *&&, Ms::EditData &) std_function.h 297 0x55f0ed
9 std::function::operator()(Ms::Score *, Ms::EditData&) const std_function.h 687 0x10d8e4d
10 Ms::Score::cmd cmd.cpp 4327 0x54d14b
11 Ms::ScoreView::cmd scoreview.cpp 2895 0x64c505
12 Ms::ScoreView::cmd scoreview.cpp 2089 0x643b87
13 Ms::MuseScore::cmd musescore.cpp 6617 0x433ff0
14 Ms::MuseScore::cmd musescore.cpp 6044 0x43093a
15 Ms::MuseScore::qt_static_metacall moc_musescore.cpp 610 0x5f057d
16 void doActivate(QObject *, int, void * *) 0x68b978bb
17 Ms::ScoreTab::actionTriggered moc_scoretab.cpp 226 0x60f9e8
18 Ms::ScoreTab::qt_static_metacall moc_scoretab.cpp 111 0x60f457
19 void doActivate(QObject *, int, void * *) 0x68b978bb
20 QActionGroupPrivate::_q_actionTriggered() 0x33084cc2
...

Possible fix (certainly prevents the crash):

diff --git a/libmscore/edit.cpp b/libmscore/edit.cpp
index 61ce4c243c..e186a07b9e 100644
--- a/libmscore/edit.cpp
+++ b/libmscore/edit.cpp
@@ -545,6 +545,8 @@ bool Score::rewriteMeasures(Measure* fm, Measure* lm, const Fraction& ns, int st
             //
             // insert new calculated measures
             //
+            if (!nfm || !nlm)
+                  return false;
             nfm->setPrev(m1->prev());
             nlm->setNext(m2->next());
             s->undo(new InsertMeasures(nfm, nlm));

Maybe a better fix (doesn't break out the loop premature):

diff --git a/libmscore/edit.cpp b/libmscore/edit.cpp
index 61ce4c243c..e186a07b9e 100644
--- a/libmscore/edit.cpp
+++ b/libmscore/edit.cpp
@@ -545,6 +545,8 @@ bool Score::rewriteMeasures(Measure* fm, Measure* lm, const Fraction& ns, int st
             //
             // insert new calculated measures
             //
+            if (!nfm || !nlm)
+                  continue;
             nfm->setPrev(m1->prev());
             nlm->setNext(m2->next());
             s->undo(new InsertMeasures(nfm, nlm));
Title Crash on delete time signature Crash on deleting certain time signatures in front of multimeasure rests
Workaround No Yes

Crashes only if multimeasure rests are shown (so toggling those off is a workaround)

Title Crash on deleting certain time signatures in front of multimeasure rests Crash on deleting time signatures in front of multimeasure rests
Fix version
4.0.0