Segfault when creating new score from Empty Score via Wizard because there is no first measure.

• Jan 24, 2017 - 16:36

I'm on latest master c82b63b on Windows 10 x86-64. If I:

  1. Start MuseScore
  2. Select Create New Score in Wizard
  3. press next without inputting title
  4. select "Empty Score"
  5. press next and finish

Result is immediate SegFault with the following callstack:

1   Ms::MeasureBase::prev                                                                                                        measurebase.h      98   0xdd926c   
2   Ms::MeasureBase::prevMeasureMM                                                                                               measurebase.cpp    241  0x83bad3   
3   Ms::Score::doLayoutRange                                                                                                     layout.cpp         3395 0x88a4a6   
4   Ms::Score::update                                                                                                            cmd.cpp            201  0x79ac3d   
5   Ms::readScore                                                                                                                file.cpp           2156 0x5a2f2d   
6   Ms::MuseScore::newFile                                                                                                       file.cpp           509  0x594492   
7   Ms::MuseScore::cmd                                                                                                           musescore.cpp      4689 0x49e375   
8   Ms::MuseScore::cmd                                                                                                           musescore.cpp      4524 0x49d7e8   
9   Ms::MuseScore::qt_static_metacall                                                                                            moc_musescore.cpp  733  0x69a9ec   
10  ZN11QMetaObject8activateEP7QObjectiiPPv                                                                                                              0x68a08842 
11  ZN12QActionGroup7hoveredEP7QAction                                                                                                                   0x1d7e5295 
12  ??                                                                                                                                                   0x2085ba48 
13  ZN7QAction8activateENS_11ActionEventE                                                                                                                0x1d7e4248 
14  ??                                                                                                                                                   0x1d1ecba8 
15  Ms::Startcenter::newScore                                                                                                    startcenter.cpp    100  0x6634ba   
16  Ms::Startcenter::loadScore                                                                                                   startcenter.cpp    85   0x663445   
17  QtPrivate::FunctorCall, QtPrivate::List, void, void (Ms::Startcenter:: *)(QString)>::call qobjectdefs_impl.h 501  0xdbe970   
18  QtPrivate::FunctionPointer::call, void>                        qobjectdefs_impl.h 520  0xdbeece   
19  QtPrivate::QSlotObject, void>::impl                            qobject_impl.h     143  0xdbeaf3   
20  ZN11QMetaObject8activateEP7QObjectiiPPv                                                                                                              0x68a08d6e 
... 

Setting a breakpoint at https://github.com/musescore/MuseScore/blob/master/libmscore/layout.cpp… has revelead that MeasureBase* m is first set to NULL because tick2measure returns null. Which makes sense cause there are no measures. That if (m == 0) test is true, so then m is assigned to first(). But because there is no first measure, m is still NULL. Therefore the next line will segfault when dereferencing m->prevMeasureMM() since m is NULL. Now the way I would fix this is that at the top of Score::doLayoutRange, I would immediately exit if both (stick == 0 && etick == 0). Sorry I have been so away from development, but this seems like an easy fix.

I also wanted to make a note of some other segfault which I unfortunately can't seem to figure out the reproduction steps, but it was something like this:

  1. Start with default new score
  2. Add a key signature(s) (and maybe delete key signatures)
  3. Select Meas 3 till end of score
  4. Ctrl->Delete
  5. Ctrl->Z

but not that exactly since I can't reproduce...

Anyway, here is the resulting call stack if that is any use:

1  Ms::SegmentList::first                                                                                         segmentlist.h     40   0xdd9594   
2  Ms::Measure::first                                                                                             measure.h         149  0xde1918   
3  Ms::Score::undoRemoveMeasures                                                                                  undo.cpp          2895 0x75562a   
4  Ms::Score::deleteMeasures                                                                                      edit.cpp          1831 0x7bfdbe   
5  Ms::Score::localTimeDelete                                                                                     edit.cpp          2862 0x7c50a6   
6  Ms::Score::cmdTimeDelete                                                                                       cmd.cpp           2977 0x7a5c4a   
7  Ms::Score::::operator()(void) const                                                                  cmd.cpp           3250 0x7a6f4d   
8  std::_Function_handler>::_M_invoke(const std::_Any_data &) functional        2039 0x7afd97   
9  std::function::operator()() const                                                                     functional        2439 0xe1d652   
10 Ms::Score::cmd                                                                                                 cmd.cpp           3268 0x7a825a   
11 Ms::ScoreView::cmd                                                                                             scoreview.cpp     3260 0x414535   
12 Ms::MuseScore::cmd                                                                                             musescore.cpp     4978 0x49fb84   
13 Ms::MuseScore::cmd                                                                                             musescore.cpp     4524 0x49d7e8   
14 Ms::MuseScore::qt_static_metacall                                                                              moc_musescore.cpp 733  0x69a9ec   
15 ZN11QMetaObject8activateEP7QObjectiiPPv                                                                                               0x68a08842 
16 Ms::ScoreTab::actionTriggered                                                                                  moc_scoretab.cpp  193  0x6a0d0b   
17 Ms::ScoreTab::qt_static_metacall                                                                               moc_scoretab.cpp  95   0x6a09dd   
18 ZN11QMetaObject8activateEP7QObjectiiPPv                                                                                               0x68a08842 
19 ZN12QActionGroup7hoveredEP7QAction                                                                                                    0x1dbc5295 
20 ??                                                                                                                                    0x23ae6e28 
21 ZN7QAction8activateENS_11ActionEventE                                                                                                 0x1dbc4248 
22 ??                                                                                                                                    0x1d1ecdb8 
23 ??                                                                                                                                    0x1fce0470 
24 ZN7QThread18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv                                                                      0x68a67dd0 
25 ZN7QThreadD2Ev                                                                                                                        0x6889aa20 
26 ZN7QObject11customEventEP6QEvent                                                                                                      0x68a06850 
27 ZN26QAbstractDynamicMetaObjectD2Ev                                                                                                    0x68a06820 
28 ZN7QObject10timerEventEP11QTimerEvent                                                                                                 0x68a06830 
29 ZN7QObject10childEventEP11QChildEvent                                                                                                 0x68a06840 
30 ZN7QObject11eventFilterEPS_P6QEvent                                                                                                   0x68a06860 
31 ZN7QObject13connectNotifyERK11QMetaMethod                                                                                             0x68a06870 
32 ZN10QSemaphore10tryAcquireEii                                                                                                         0x6889a350 

Comments

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