Crash on corrupt MXL import
Reported version
3.6
Type
Functional
Frequency
Once
Severity
S2 - Critical
Reproducibility
Always
Status
closed
Regression
No
Workaround
No
Project
I run a self-built MuseScore, currently from commit #84f6aa76ca2a9a3b41b5114b1715ab23b09f2887 in the 3.x branch. I came across a MusicML file (produced by Audiveris) that is flagged as corrupt on import. Since those messages can usually be ignored for native project files I decided to ignore the warning and import the file anyway as suggested by the dialog.
A crash ensued, AFAICT as a result of a vulgar nullptr derefence. Fixed as in the patch below the file imports to an empty score - vastly preferable over a crash.
diff --git a/importexport/musicxml/importmxmlpass2.cpp b/importexport/musicxml/importmxmlpass2.cpp index 35699718..125769af 100644 --- a/importexport/musicxml/importmxmlpass2.cpp +++ b/importexport/musicxml/importmxmlpass2.cpp @@ -1579,8 +1579,9 @@ void MusicXMLParserPass2::scorePartwise() } // set last measure barline to normal or MuseScore will generate light-heavy EndBarline // TODO, handle other tracks? - if (_score->lastMeasure()->endBarLineType() == BarLineType::NORMAL) - _score->lastMeasure()->setEndBarLineType(BarLineType::NORMAL, 0); + auto lm = _score->lastMeasure(); + if (lm && lm->endBarLineType() == BarLineType::NORMAL) + lm->setEndBarLineType(BarLineType::NORMAL, 0); } //---------------------------------------------------------
The mxl file: JustinJohnson-BlackwoodLullaby-notab3-p4-crash.mxl
Fix version
4.0.0
Comments
(if you enclose the code in <cpp>...</cpp> it renders better):
I'm not sure whether an empty score really is an improvement though?
OTOH:
Debug: importMusicXml() file '.../JustinJohnson-BlackwoodLullaby-notab3-p4-crash.mxl' is not a valid MusicXML file (...\importexport\musicxml\importxml.cpp:203, Ms::Score::FileError Ms::doValidate(const QString&, QIODevice*))
Debug: empty score (...\libmscore\layout.cpp:4899, void Ms::Score::doLayoutRange(const Ms::Fraction&, const Ms::Fraction&))
and looking at the xml:
That score really is empty, so yes, this is an improvement!
Are you going to PR it?
Else I'd do it, just let me know
If so, do it on top of the master branch (too)
In reply to Are you going to PR it? Else… by Jojo-Schmitz
>Are you going to PR it?
>Else I'd do it, just let me know
I was hoping one of the devs would do it indeed, given how simple the change is (and based on another nullptr check on the same property in the same file).
Re: is it an improvement aside from the fact that this was really an empty score; when I import something that is flagged as corrupt or invalid I expect anything up to a definitive failure message, but not really a hard crash.
BTW, is the warning dialog appropriate if this is really an empty score?
If the score were not empty, that warning were bogus, but it is, so it isn't ;-)
See https://github.com/musescore/MuseScore/pull/8199 (for 3.x)
and https://github.com/musescore/MuseScore/pull/8200 (for master)
Fixed in branch 3.x, commit f7639dc723
Fix #321730: Crash on corrupt MXL import
Fixed in branch 3.x, commit 45522a4821
_Merge pull request #8199 from Jojo-Schmitz/mxl-crash-3.x
[MU3] Fix #321730: Crash on corrupt MXL import_
Fixed in branch master, commit 9e416536cf
Fix #321730: Crash on corrupt MXL import
Fixed in branch master, commit 7db06a6707
_Merge pull request #8200 from Jojo-Schmitz/mxl-crash-master
[MU4] Fix #321730: Crash on corrupt MXL import_
Automatically closed -- issue fixed for 2 weeks with no activity.