Crash on importing MusicXML

• Mar 22, 2022 - 10:23

Trying to open MusicXML files, I experience multiple crashes. One is with an empty file, with no content. MuseScore complains that "Element part-list is missing child element." , which is OK, but if I answer "Yes" to the question "Do you want to try to load this file anyway", MuseScore crashes.

If I try to open another file with content, it opens without questions or problems. But then, if I select the whole content, either by clicking in the first measure and shift-clicking in the last one, or clicking in the first measure and typing Ctrl+Shift+end, MuseScore crashes.

If I select progressively, clicking in the first measure, then Shift-clicking every five or six measures, I can succeed in selecting the whole staff and copying it. After that, selection works normally. (I can deselect and reselect directly from first to last measure.) Not sure whether this is due to my configuration or a more general problem.

Attachment Size
OneNoteSamba_music.xml 422 bytes
OneNoteSamba_alto1.xml 118.81 KB

Comments

No crash here (on that OneNoteSamba_music.xml), MuseScore 3.6.2 on Windows 11, but no import either. And no wonder, looking at the (very little) content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 2.0 Partwise//EN"
                                "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.0">
  <identification>
    <encoding>
      <software>Frescobaldi 3.1.3</software>
      <encoding-date>2022-03-22</encoding-date>
    </encoding>
  </identification>
  <part-list />
</score-partwise>

It is basically empty, so there's nothing to import. As it doesn't crash (for me at least) I'm not sure this is worth fixing?

In reply to by Jojo-Schmitz

Seems yet another simple 1-line fix, added to PR #9000

But the crash in that PR (before the fix) is different from the one in 3.6.2, and also doesn't happen at all in the 3.x branch (which PR #9000 is based on)
So it seems the issue got fixed in 3.x and then broke again later, looking that fix I came up with in https://github.com/musescore/MuseScore/pull/8530, which in turn isn't (yet) in master...

I can confirm the crash on 'Ctrl+A' on that other score though, OneNoteSamba_alto1.xml

Stack trace:

1 Ms::Element::parent element.h 199 0x1061a7c
2 Ms::Segment::measure segment.h 130 0x10631b8
3 Ms::Segment::tick segment.cpp 214 0xa8b436
4 Ms::Selection::appendChord select.cpp 505 0xa9657c
5 Ms::Selection::updateSelectedElements select.cpp 589 0xa96fe1
6 Ms::Score::selectRange score.cpp 3313 0xa8018f
7 Ms::Score::cmdSelectAll score.cpp 3724 0xa81c32
8 Ms::Score::::operator()(Ms::Score *, Ms::EditData &) const cmd.cpp 4275 0x54ade4
9 std::_Function_handler>::_M_invoke(const std::_Any_data &, Ms::Score *&&, Ms::EditData &) std_function.h 297 0x55d2ba
10 std::function::operator()(Ms::Score *, Ms::EditData&) const std_function.h 687 0x10d022d
11 Ms::Score::cmd cmd.cpp 4327 0x54d1db
12 Ms::ScoreView::cmd scoreview.cpp 2895 0x64c5c5
13 Ms::ScoreView::cmd scoreview.cpp 2089 0x643c47
14 Ms::MuseScore::cmd musescore.cpp 6617 0x433ff0
15 Ms::MuseScore::cmd musescore.cpp 6044 0x43093a
16 Ms::MuseScore::qt_static_metacall moc_musescore.cpp 610 0x5f060d
17 void doActivate(QObject *, int, void * *) 0x68b978bb
18 Ms::ScoreTab::actionTriggered moc_scoretab.cpp 226 0x60fa78
19 Ms::ScoreTab::qt_static_metacall moc_scoretab.cpp 111 0x60f4e7
20 void doActivate(QObject *, int, void * *) 0x68b978bb
...

In reply to by Jojo-Schmitz

Easy 1-line fix:

diff --git a/libmscore/select.cpp b/libmscore/select.cpp
index 3b797bbbfd..c075455fb1 100644
--- a/libmscore/select.cpp
+++ b/libmscore/select.cpp
@@ -502,7 +502,7 @@ void Selection::appendChord(Chord* chord)
                   if (sp->endElement()->isNote()) {
                         Note* endNote = toNote(sp->endElement());
                         Segment* s = endNote->chord()->segment();
-                        if (s->tick() < tickEnd())
+                        if (s && s->tick() < tickEnd())
                               _el.append(sp);
                         }
                   }

I'll add it to my PR #9000 and will check whether it is neeeded for master (which will become MuseScore 4) too

The OneNoteSambe_alto1.xml crash is triggered when adding measure 43's last note to the selection (1/8 F4 at measure 43 beat 4.5). It contains an invisible glissando with an end note at tick 0/1.

The MusicXML file indeed has a glissando start at that note and a corresponding glissando stop in the next measure at a grace note attached to a rest. The grace note is invisible in MuseScore's GUI, which may indicate an import problem leading to the issue.

File OneNoteSamba_music.xml does cause a crash for me (3.x on MacOS). Suspect uninitialised memory, as the MusicXML file does not contain any music and the crash is caused by a null pointer. Stack trace:
* frame #0: 0x000000010127fecc mscoreMs::SegmentList::last(this=0x0000000000000128) const at segmentlist.h:46
frame #1: 0x00000001012593fc mscore
Ms::Measure::last(this=0x0000000000000000) const at measure.h:153
frame #2: 0x00000001011193fe mscoreMs::Measure::endBarLine(this=0x0000000000000000) const at measure.cpp:3648
frame #3: 0x00000001011196b5 mscore
Ms::Measure::endBarLineType(this=0x0000000000000000) const at measure.cpp:3669
frame #4: 0x0000000100ddc06b mscoreMs::MusicXMLParserPass2::scorePartwise(this=0x00007ffeefbfbcb8) at importmxmlpass2.cpp:1582
frame #5: 0x0000000100ddbd53 mscore
Ms::MusicXMLParserPass2::parse(this=0x00007ffeefbfbcb8) at importmxmlpass2.cpp:1542
frame #6: 0x0000000100ddbcb8 mscoreMs::MusicXMLParserPass2::parse(this=0x00007ffeefbfbcb8, device=0x00007ffeefbfc290) at importmxmlpass2.cpp:1523
frame #7: 0x0000000100d9cc9a mscore
Ms::importMusicXMLfromBuffer(score=0x000000010d588800, (null)=0x00007ffeefbfc680, dev=0x00007ffeefbfc290) at importmxml.cpp:57
frame #8: 0x0000000100e2062f mscoreMs::doValidateAndImport(score=0x000000010d588800, name=0x00007ffeefbfc680, dev=0x00007ffeefbfc290) at importxml.cpp:235
frame #9: 0x0000000100e208ac mscore
Ms::importMusicXml(score=0x000000010d588800, name=0x00007ffeefbfc680) at importxml.cpp:281

In reply to by Leon Vinken

The fix for that is simple:

@@ -1497,7 +1497,7 @@ static void resetTuplets(Tuplets& tuplets)
 
static void cleanFretDiagrams(Measure* measure)
      {
-      if (measure->no() > 0)
+      if (!measure || measure->no() > 0)
            return;
      // Case 1: Dummy hidden first measure with all fretboards attached
      bool isDummyMeasure = toMeasureBase(measure)->lineBreak();

And not needed in 3.6.2 nor (yet) in master, as I outlined further up

Do you still have an unanswered question? Please log in first to post your question.