[MusicXML import] crash when importing file with fermata

• Mar 2, 2018 - 07:08
Reported version
3.0
Priority
P1 - High
Type
Functional
Severity
S2 - Critical
Reproducibility
Always
Status
closed
Regression
No
Workaround
No
Project

See attached test file, which crashes current master, while 2.x imports it without errors and shows the fermata on the grace note.

Attachment Size
fermata_on_grace_note.musicxml 2.12 KB

Comments

Title [MusicXML import] crash when importing file with fermata on grace note [.mscz import] crash when importing file with fermata
Status (old) patch (code needs review) active
Status active

I would like to expand this to include fermatas on regular notes from mscz.
Simply opening the attached file causes an immediate crash.
This is simply one bar in the key C in 4/4 with a regular fermata without any adjustments to playback effect, and it still crashes.

Attachment Size
ideas.mscz 2.58 KB

In reply to by GunsAndChips

Indeed the symptoms are identical (calling Segment::add() on a nullptr segment resulting in a crash). Although in both cases this happens when adding a fermata, the actual location where the nullptr access is caused differs, thus these should be considered separate bugs. Stack traces:

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008

VM Regions Near 0x8:
-->
__TEXT 0000000106448000-0000000107b71000 [ 23.2M] r-x/rwx SM=COW /Users/USER/*/mscore.app/Contents/MacOS/mscore

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 org.musescore.MuseScore 0x00000001064a433c Ms::ScoreElement::score() const + 12 (scoreElement.h:176)
1 org.musescore.MuseScore 0x00000001071df477 Ms::Segment::add(Ms::Element) + 151 (segment.cpp:442)
2 org.musescore.MuseScore 0x0000000106978f63 Ms::addFermataToChord(Ms::ChordRest
, Ms::SymId, bool) + 195 (importmxmlpass2.cpp:1163)
3 org.musescore.MuseScore 0x000000010697256b Ms::addFermata(Ms::ChordRest*, QString, Ms::SymId) + 91 (importmxmlpass2.cpp:1325)
4 org.musescore.MuseScore 0x0000000106971092 Ms::MusicXMLParserPass2::fermata(Ms::ChordRest) + 498 (importmxmlpass2.cpp:5918)
5 org.musescore.MuseScore 0x0000000106967ae1 Ms::MusicXMLParserPass2::notations(Ms::Note
, Ms::ChordRest*, int, Ms::MusicXmlTupletDesc&, bool&) + 1697 (importmxmlpass2.cpp:5824)
6 org.musescore.MuseScore 0x00000001069543bb Ms::MusicXMLParserPass2::note(QString const&, Ms::Measure*, Ms::Fraction, Ms::Fraction, Ms::Fraction&, QString&, QList&, int&, Ms::Beam&, QVector&, int&) + 11435 (importmxmlpass2.cpp:4486)
7 org.musescore.MuseScore 0x000000010694b15e Ms::MusicXMLParserPass2::measure(QString const&, Ms::Fraction) + 2638 (importmxmlpass2.cpp:2028)
8 org.musescore.MuseScore 0x00000001069492b8 Ms::MusicXMLParserPass2::part() + 2152 (importmxmlpass2.cpp:1701)
9 org.musescore.MuseScore 0x0000000106948933 Ms::MusicXMLParserPass2::scorePartwise() + 307 (importmxmlpass2.cpp:1592)
10 org.musescore.MuseScore 0x00000001069486e3 Ms::MusicXMLParserPass2::parse() + 131 (importmxmlpass2.cpp:1561)
11 org.musescore.MuseScore 0x0000000106948648 Ms::MusicXMLParserPass2::parse(QIODevice
) + 56 (importmxmlpass2.cpp:1541)
12 org.musescore.MuseScore 0x0000000106915b6a Ms::importMusicXMLfromBuffer(Ms::Score*, QString const&, QIODevice) + 314 (importmxml.cpp:55)
13 org.musescore.MuseScore 0x00000001069bb04f Ms::doValidateAndImport(Ms::Score
, QString const&, QIODevice) + 79 (importxml.cpp:235)
14 org.musescore.MuseScore 0x00000001069bafb8 Ms::importMusicXml(Ms::MasterScore
, QString const&) + 568 (importxml.cpp:263)
15 org.musescore.MuseScore 0x00000001066d5f3e Ms::readScore(Ms::MasterScore*, QString, bool) + 2078 (file.cpp:2188)
16 org.musescore.MuseScore 0x00000001066d53f5 Ms::MuseScore::readScore(QString const&) + 181 (file.cpp:329)
17 org.musescore.MuseScore 0x0000000106b6fa48 Ms::loadScores(QStringList const&) + 2328 (musescore.cpp:2606)
18 org.musescore.MuseScore 0x0000000106b6d9ab main + 51163 (musescore.cpp:6361)
19 org.musescore.MuseScore 0x0000000106453cc4 start + 52

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008

VM Regions Near 0x8:
-->
__TEXT 00000001082b5000-00000001099de000 [ 23.2M] r-x/rwx SM=COW /Users/USER/*/mscore.app/Contents/MacOS/mscore

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 org.musescore.MuseScore 0x000000010831133c Ms::ScoreElement::score() const + 12 (scoreElement.h:176)
1 org.musescore.MuseScore 0x000000010904c477 Ms::Segment::add(Ms::Element) + 151 (segment.cpp:442)
2 org.musescore.MuseScore 0x0000000108fd31c7 Ms::readRest(Ms::Rest
, Ms::XmlReader&) + 343 (read206.cpp:1489)
3 org.musescore.MuseScore 0x0000000108fce8fc Ms::readMeasure(Ms::Measure*, int, Ms::XmlReader&) + 4540 (read206.cpp:1624)
4 org.musescore.MuseScore 0x0000000108fcbc44 Ms::readStaffContent(Ms::Score*, Ms::XmlReader&) + 484 (read206.cpp:2128)
5 org.musescore.MuseScore 0x0000000108fc9787 Ms::readScore(Ms::Score*, Ms::XmlReader&) + 151 (read206.cpp:2277)
6 org.musescore.MuseScore 0x0000000108fc9136 Ms::MasterScore::read206(Ms::XmlReader&) + 598 (read206.cpp:2591)
7 org.musescore.MuseScore 0x000000010904608f Ms::MasterScore::read1(Ms::XmlReader&, bool) + 751 (scorefile.cpp:927)
8 org.musescore.MuseScore 0x00000001090458c5 Ms::MasterScore::loadCompressedMsc(QIODevice*, bool) + 1365 (scorefile.cpp:793)
9 org.musescore.MuseScore 0x00000001090463f4 Ms::MasterScore::loadMsc(QString, QIODevice*, bool) + 180 (scorefile.cpp:844)
10 org.musescore.MuseScore 0x00000001090462d3 Ms::MasterScore::loadMsc(QString, bool) + 227 (scorefile.cpp:836)
11 org.musescore.MuseScore 0x0000000108542879 Ms::readScore(Ms::MasterScore*, QString, bool) + 345 (file.cpp:2130)
12 org.musescore.MuseScore 0x00000001085423f5 Ms::MuseScore::readScore(QString const&) + 181 (file.cpp:329)
13 org.musescore.MuseScore 0x00000001089dca48 Ms::loadScores(QStringList const&) + 2328 (musescore.cpp:2606)
14 org.musescore.MuseScore 0x00000001089da9ab main + 51163 (musescore.cpp:6361)
15 org.musescore.MuseScore 0x00000001082c0cc4 start + 52

Status (old) patch (code needs review) active
Status active

Cause of crash understood: the MusicXML importer tries to attach the fermata to the current note's segment. Unfortunately, for a grace note the segment will be the parent note's segment, which does not yet exist at this time during import.

Structural solution would be to remember the fermata until the parent note and its segment have been created.

In reply to by Anatoly-os

The patch mentioned above was reviewed by @lasconic and me, it was rejected. The idea it implements could be right, but for me the implementation did not work correctly, so further work is required. Status active is correct (unless another patch is available that I am not aware of).

Severity S4 - Minor S2 - Critical

It does crash on it, when using File/Open or the corresponding icon in the toolbar.

No crash and no open when just dragging the file into the MuseScore window, this seems to happen quite frequently, and may be a bug of its own.

Stack trace (in a MinGW build, when opening the musicxml file from the initial post):

1 Ms::ScoreElement::score scoreElement.h 186 0xf57cac
2 Ms::Segment::add segment.cpp 443 0x8b7aa8
3 Ms::addFermataToChord importmxmlpass2.cpp 1164 0x45b847
4 Ms::addFermata importmxmlpass2.cpp 1326 0x45cc99
5 Ms::MusicXMLParserPass2::fermata importmxmlpass2.cpp 5920 0x479c35
6 Ms::MusicXMLParserPass2::notations importmxmlpass2.cpp 5826 0x478f43
7 Ms::MusicXMLParserPass2::note importmxmlpass2.cpp 4486 0x46e85c
8 Ms::MusicXMLParserPass2::measure importmxmlpass2.cpp 2031 0x45f85e
9 Ms::MusicXMLParserPass2::part importmxmlpass2.cpp 1704 0x45e0c8
10 Ms::MusicXMLParserPass2::scorePartwise importmxmlpass2.cpp 1594 0x45d668
11 Ms::MusicXMLParserPass2::parse importmxmlpass2.cpp 1563 0x45d488
12 Ms::MusicXMLParserPass2::parse importmxmlpass2.cpp 1544 0x45d40b
13 Ms::importMusicXMLfromBuffer importmxml.cpp 55 0x4464f3
14 Ms::doValidateAndImport importxml.cpp 233 0x67e61c
15 Ms::importMusicXml importxml.cpp 263 0x67e7c0
16 Ms::readScore file.cpp 2212 0x602309
17 Ms::MuseScore::readScore file.cpp 331 0x5f04a0
18 Ms::MuseScore::openScore file.cpp 312 0x5f0378
19 Ms::MuseScore::loadFiles file.cpp 293 0x5effdc
20 Ms::MuseScore::cmd musescore.cpp 5319 0x4c7429
...