Crash when starting in debug mode with -d flag

• Jun 4, 2014 - 11:16
Type
Functional
Severity
S2 - Critical
Status
closed
Project

Steps:
1- compile MuseScore in debug mode;
2- launch mscore with "-d" flag;
3- when the Promenade example is loaded, MuseScore crashes (the code reaches an assert, which is inside an "if (MScore::debugMode)" condition).

Windows 8.1, commit d5b3159

Command prompt output:
Fatal: time 0.000000 not found in RepeatList
(C:\Git_packages\MuseScore\libmscore\repeatlist.cpp:230, int Ms::RepeatList::utime2utick(qreal) const)


Comments

looking at the code this seems to be by design?
{syntaxhighlighter brush:cpp;first-line:219;highlight:[230]}
int RepeatList::utime2utick(qreal t) const
{
unsigned n = size();
unsigned ii = (idx2 < n) && (t >= at(idx2)->utime) ? idx2 : 0;
for (unsigned i = ii; i < n; ++i) {
if ((t >= at(i)->utime) && ((i + 1 == n) || (t < at(i+1)->utime))) {
idx2 = i;
return _score->tempomap()->time2tick(t - at(i)->timeOffset) + (at(i)->utick - at(i)->tick);
}
}
if (MScore::debugMode) {
qFatal("time %f not found in RepeatList\n", t);
}
return 0;
}{/syntaxhighlighter}

Seems it is expected to take the earlier return to leave this function, but for some reason in the Promenade example it does not?

No, you didn't read my reply. The code segment you're looking at is still wrong. The function name should be "RepeatList::utime2utick", you're showing "RepeatList::utick2tick(int tick) const". Here's what I see starting at line 219 in libmscore\repeatlist.cpp:

int RepeatList::utime2utick(qreal t) const
{
unsigned n = size();
unsigned ii = (idx2 < n) && (t >= at(idx2)->utime) ? idx2 : 0;
for (unsigned i = ii; i < n; ++i) {
if ((t >= at(i)->utime) && ((i + 1 == n) || (t < at(i+1)->utime))) {
idx2 = i;
return _score->tempomap()->time2tick(t - at(i)->timeOffset) + (at(i)->utick - at(i)->tick);
}
}
if (MScore::debugMode) {
qFatal("time %f not found in RepeatList\n", t);
}
return 0;
}

It crashes also under Linux Mint 13, and while opening any score (or creating a new one).
This problem is present since commit c1725a21, the previous commit does not exhibit this behavior.

It seems that the problem arises from the fact that at line 713 of seq.cpp function getCurTick() is called and at line 930 of seq.cpp
{syntaxhighlighter brush:c++;first-line:930;} return cs->utime2utick(qreal(playTime) / qreal(MScore::sampleRate));{/syntaxhighlighter}
in this case playTime is 0.
A possible workaround could be a check over playTime, by changing line 713 of seq.cpp from
{syntaxhighlighter brush:c++;first-line:713;} if(cs && cs->sigmap()->timesig(getCurTick()).nominal()!=prevTimeSig) {{/syntaxhighlighter}
to
{syntaxhighlighter brush:c++;first-line:713;} if(cs && playTime && cs->sigmap()->timesig(getCurTick()).nominal()!=prevTimeSig) {{/syntaxhighlighter}
I don't know if this change could break any particular case: I don't really understand the sound output code, but I noticed that somewhere else a check of (playTime != 0) is performed (line 523 of seq.cpp).

Status (old) active fixed

As a workaround i commented out some code in seq.cpp process(). Another solution has to be found as use of signal/slot ipc is not allowed in this realtime function.