Crash by undoing/redoing in main score a copy-paste made in the parts

• Oct 29, 2019 - 21:31
Reported version
3.2
Priority
P0 - Critical
Type
Functional
Frequency
Once
Severity
S2 - Critical
Reproducibility
Always
Status
closed
Regression
Yes
Workaround
No
Project

Version 3.2.3 and current 3.3. R.C.

Steps with minimal score:

1) Default score (one measure is enough, with a whole note)
2) Create Part
(the test file: minimal.mscz )
3) From main score: Copy the single measure
4) Paste it in Part
5) Return in main score (necessary condition) : Undo + Redo

----------------------------> Crash


Comments

This appears to be the result of a very recent commit, specifically 710cd6a. The crash can be prevented by simply checking if _startSegment is not null before dereferencing it. But it worries me that _startSegment is null, given that _state is equal to SelState::RANGE.

Regression No Yes

Hmm, sure? @cadiz1 reported it to happen with 3.2.3 already

Anyway, it does the same check in the SelState::LIST case, so I see no harm in doing it for the SelState::RANGE case too
How about this:

diff --git a/libmscore/select.cpp b/libmscore/select.cpp
index e82fbe019..8486240be 100644
--- a/libmscore/select.cpp
+++ b/libmscore/select.cpp
@@ -83,7 +83,7 @@ Fraction Selection::tickStart() const
       {
       switch (_state) {
             case SelState::RANGE:
-                  return _startSegment->tick();
+                  return _startSegment ? _startSegment->tick() : Fraction(-1,1);
             case SelState::LIST: {
                   ChordRest* cr = firstChordRest();
                   return (cr) ? cr->tick() : Fraction(-1,1);

Jojo, the change that you propose is identical to the one that I tried, and it does indeed prevent the crash, and it certainly does not do any harm. It would probably be a good idea to get this fix into 3.3, which will be released tomorrow.

Fix version
3.3.0