Crash when removing a section break, or by various editing work before it, in a score with parts and MM rests
Reported version
3.0
Priority
P0 - Critical
Type
Functional
Frequency
Many
Severity
S1 - Blocker
Reproducibility
Always
Status
closed
Regression
Yes
Workaround
No
Project
3.0.2 /Windows10
- First scenario (test file: section break parts.mscz )
1) Default score
2) Add a section break
3) Generate parts
4) In main score: Select and cut the section break
Result: crash
- Second scenario (test file: test section break parts.mscz )
1) Default score
2) Enter a few notes in first measure
3) Add a section break measure 8 eg
4) Generate parts
5) In main score: copy-paste first measure before section break (eg in measure 4 or 5 on the test file)
Result: crash
- Note in these scenarios: no issue if disabling mm rests in part before last crucial step(s).
Fix version
3.0.4
Comments
Came up again in https://musescore.org/en/node/283352
Really dangerous issue and with several aspects and impacts.
Came up again in: https://musescore.org/en/node/283491
Ran the test through gdb and came up with this:
As can be seen in #0 'this' is null, so the pause method dereference will cause sigsegv.
If looking at the code in #1, measurebase.cpp around 267 we see:
Now this code assumes sectionBreakElement() always returns an object and not NULL.
This is not the case as can be seen in measurebase.cpp:603 :
It SEEMS to be the cause in this case, but perhaps there is other ways to trigger the same bug.
EDIT: cleaned up formatting.
Maybe fixing it as:
sectionBreakElement() Seems to be used in a similar fashion at other places too.
It seems that they assume sectionBreakElement() always returns an object as long as sectionBreak() holds. But sectionBreakElement() also needs isLayoutBreak() on any element it returns.
Possible other places where (perhaps) similar bug could appear?
It seems when pressing delete on the section-break element. The element is removed from a measure, and cascade-removed from others (master and foreach part). But on one of measure, it gets removed, but the flag is not resetted.
The removal is done by the element disappearing from the measure's ElementList.
See the kludge-comment in the patch below for more details.
The patch works by cleaning up the measure during layout, it is a bit kludgy and would need future cleanup (removal).
Other fatal scenario:
1) Load the first attachment ie: test section break parts.mscz
2) Select whole rest let's say two measures before the section break (or simply in the same measure)
3) Ctrl + M, for adding a rehearsal mark
Result: crash
Other aspects and fatal scenarios:
1) Load the first attachment ie: test section break parts.mscz
2) Select whole rest let's say two measures before the section break
3) Insert new time signature
(same result if inserting key signature, or attempt to change the whole rest value in two half rests ,etc, etc.) and probably some others.
Result: crash
Given the magnitude of the scenarios involved and in common use cases, and the consequences on scores and the degraded image on the stability of the program right now (eg: https://musescore.org/en/node/283639, following a bad experience related to this issue), I really think that this issue deserves the "Blocker" status.
"and probably some others"
As articulations, ie fermatas, and repeat symbols (Fine, D.C. etc)
I don't think it is necessary to insist further: this issue must be fixed as soon as possible, really.
Found it.
A side effect of this commit on October 13, 2016 : https://github.com/musescore/MuseScore/commit/b511d0a490a11dad4954692c5…
Indeed, no crash with the previous nightly: 2b44d04
And so, crash with this one: b511d0a
I think I've found the root-cause, it calls for a much simpler patch, I have a more prepared patch with more safety checks and code doc, but show the most relevant change below.
One of the measures ( a MMR), gets in an inconsistent state during layout ( blame Score::createMMRest ).
It deletes the elementlist from the measure without updating the measure flag-cache.
That responsibility is moved to measurebase.cpp by the patch.
In reply to I think I've found the root… by larryz
Another one:
1) Load this file: test section break parts.mscz
2) Switch in Part
3) Press "M" for disable mm rests
4) Remove the section break
5) Press again "M"
----> crash
Confirming crash with file "test section break parts.mscz" and procedure described (pressing M, delete sec-brk, pree M).
Also with my patch applied, same procedure wont crash and works as expected as far as I can see.
@larryz: Are you going to submit a Pull Request?
Title more adapted now to the variety of situations leading to crash the program.
Sure I'll submit a github-pr, my username there is "lyrra", I've agreed to transfer copyright ownership, is that enough?
Regarding this issue, the very presence of MeasureBase::cleanupLayoutBreaks() hints of some underlying problem. My patch doesn't address that.
You'd need to sign the CLA
Edit: I see you did already
See https://github.com/musescore/MuseScore/pull/4678.
Fix grammar.
Fixed in branch master, commit f33c646862
fix #283152: crash involving section breaks on mutimeasure rests
Fixed in branch master, commit b2f32e09ab
_Merge pull request #4678 from mattmcclinch/283152-mmrest-sectionbreak
fix #283152: crash involving section breaks on mutimeasure rests_
Fixed in branch 3.0.4, commit a72f1d17e4
_Merge pull request #4678 from mattmcclinch/283152-mmrest-sectionbreak
fix #283152: crash involving section breaks on mutimeasure rests_
Automatically closed -- issue fixed for 2 weeks with no activity.