Segfault when inserting notes in linked staves after time sig change

• Sep 13, 2012 - 07:48
Type
Functional
Severity
S2 - Critical
Status
closed
Project

GIT commit: e146aba

This time I have another balalaika sheet using two linked staves based on guitars. One of them is configured to be a tab staff with three strings. Now, I can reproduce the segfault by loading the attatched file and insert a C in the first meassure. Here follows a stack trace of the segfault.

expand voice: found Rest 2/4
makeGap 1/4 at 0 track 0
remove Rest 2/4 at tick 0 track 0
makeGap: remove 2/4 at 0
makeGap: 1/4 removed 1/4 too much
dList: 1

gap at tick 0+480
addClone at 480, 480
addClone Rest at 480 1/4
Segment::add(Chord) there is already an Rest at 1:0:0(0) track 4
1/4 -> 2/4

Program received signal SIGABRT, Aborted.
0x00007ffff1aff445 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0 0x00007ffff1aff445 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff1b02bab in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00000000009897e0 in Segment::add (this=0x59d7610, el=0x5707210) at /home/johan/Projects/MuseScore/libmscore/segment.cpp:489
#3 0x0000000000982463 in Score::addElement (this=0x5950c50, element=0x5707210) at /home/johan/Projects/MuseScore/libmscore/score.cpp:1399
#4 0x00000000009dfab9 in AddElement::redo (this=0x5223850) at /home/johan/Projects/MuseScore/libmscore/undo.cpp:1267
#5 0x00000000009e28dc in UndoStack::push (this=, cmd=0x5223850) at /home/johan/Projects/MuseScore/libmscore/undo.cpp:236
#6 0x00000000009e6ea3 in Score::undoAddCR (this=0x5950c50, cr=0x629fbe0, measure=0x5960d10, tick=0)
at /home/johan/Projects/MuseScore/libmscore/undo.cpp:1153
#7 0x00000000009ee9b7 in Score::setNoteRest (this=0x5950c50, segment=, track=0, nval=..., sd=..., stemDirection=MScore::AUTO)
at /home/johan/Projects/MuseScore/libmscore/cmd.cpp:603
#8 0x00000000008feb5a in Score::putNote (this=0x5950c50, p=..., replace=true) at /home/johan/Projects/MuseScore/libmscore/edit.cpp:773
#9 0x00000000005eb299 in ScoreView::cmdAddPitch (this=0x5954c40, note=0, addFlag=)
at /home/johan/Projects/MuseScore/mscore/scoreview.cpp:4777
#10 0x00000000005ef1dd in ScoreView::cmd (this=0x5954c40, a=0x18ca460) at /home/johan/Projects/MuseScore/mscore/scoreview.cpp:2434
#11 0x00000000006d4876 in MuseScore::cmd (this=0x183b780, a=0x18ca460, cmd=...) at /home/johan/Projects/MuseScore/mscore/musescore.cpp:4418
#12 0x00000000006d4bf8 in MuseScore::cmd (this=0x183b780, a=0x18ca460) at /home/johan/Projects/MuseScore/mscore/musescore.cpp:4054
#13 0x00000000005cc1ae in MuseScore::qt_static_metacall (_o=0x183b780, _c=QMetaObject::InvokeMetaMethod, _id=49, _a=0x7fffffffc0d0)
at /home/johan/Projects/MuseScore/build.release/mscore/moc_musescore.cxx:583
#14 0x00007ffff3947281 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#15 0x00007ffff43e0c9f in QActionGroup::triggered(QAction*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#16 0x00007ffff43e0d27 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#17 0x00007ffff3947281 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#18 0x00007ffff43de132 in QAction::triggered(bool) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#19 0x00007ffff43de31f in QAction::activate(QAction::ActionEvent) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#20 0x00007ffff43de48f in QAction::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#21 0x00007ffff43e4894 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#22 0x00007ffff43e9713 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#23 0x00007ffff3932e9c in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#24 0x00007ffff44168b9 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#25 0x00007ffff4417d8a in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#26 0x00007ffff43eaf92 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#27 0x00007ffff3932e9c in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#28 0x00007ffff4488c49 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#29 0x00007ffff44890bb in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#30 0x00007ffff4463637 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#31 0x00007ffff448d0d2 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#32 0x00007fffefaa0d53 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#33 0x00007fffefaa10a0 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
---Type to continue, or q to quit---
#34 0x00007fffefaa1164 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#35 0x00007ffff39623bf in QEventDispatcherGlib::processEvents(QFlags) ()
from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#36 0x00007ffff448cd5e in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#37 0x00007ffff3931c82 in QEventLoop::processEvents(QFlags) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#38 0x00007ffff3931ed7 in QEventLoop::exec(QFlags) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#39 0x00007ffff3936f67 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#40 0x00000000005c33e6 in main (argc=1, av=) at /home/johan/Projects/MuseScore/mscore/musescore.cpp:2475
(gdb)

Attachment Size
Arnes polka.mscz 2.49 KB

Comments

I am investigating this.

Technical note: So far, I traced it to a strange behaviour of Score::makeGap() when called by Score::setNoteRest() (both in libmscore/cd.xpp): under yet unknown conditions, it seems not to make the gap for ALL the linked staves, but only for the one to which the note is physically added.

I still do not know if it is related with TAB's or it is a more general issue.

M.

Status (old) active needs info

It seems a problem with this specific score: if I use your score, it happens, but if I make from scratch a new score similar to yours, it no longer happens.

A strange thing is that I am using the same revision as yours (e146aba), under Ubuntu 11.10 (self-compiled, though). However, looking at the score text (.mscx rather than mscz), I see most elements of my score -- including all measure rests -- have an additional tag, <lid> (meaning "linked id"?) which is missing in yours; may this mean some linking is actually meaning in your score? This would explain the failure of makeGap() (see prev. post) and the SIGFAULT.

I'm attaching an example of redone score.

Your rather puzzled,

M.

Attachment Size
Arnes polka_bis.mscx 41.43 KB
Status (old) needs info active

I also fail to reproduce it when starting over from scratch now. It's hard to tell exactly what I did and in which order when I created the score. It is, however, created with the very same version of the program as the bug is filed towards.

This is very similar to the other score: most of the info about linked elements across linked staves (which element of which staff is linked with which other element of another staff) is lost. This leads to inconsistent behaviour.

It would VERY useful to know the steps you used to create this score (as well as the older one...). Possibly, in this case, which steps you performed after entering the first two measures (at that time, the info was still there, as you could enter those notes) and before trying to enter new notes in measure 3. It seems to be some specific sequence of steps which leads to loosing those info.

There is definitely something wrong, but until we find a reproducible procedure, it is like shooting in the dark.

Let's hope!

M.

Finally, I can reproduce this from scratch! It has not to do with tabs, but with linked staves:

  1. create a new document with two linked staves
  2. drag a 2/4 time signature to the first measure of the topmost staff
  3. hit n and try inserting a note
  4. cry!
Title Segfault when inserting note in sheet with linked staves Segfault when inserting notes in linked staves after time sig change

The issue is originated by the change in time signature.

If there are linked staves, the function bool Score::rewriteMeasures(Measure* fm, Measure* lm, const Fraction& ns) (file edit.cpp, line 389 and foll.) does not keep the link info; or, in other words, does not replicate it after removing and re-inserting the changed measures: all added segments have the _link member var set to 0.

This might be a fault of the function itself or of the function bool ScoreRange::write(int track, Measure* m) it calls at line 429 (the last function, in turn, calls the function bool TrackList::write(int track, Measure* measure, QHash* map) which does most of the work).

In any way, the segments of the measures added back to the score at line 441 should have proper link data. Otherwise, when entering notes, Score::makeGap() will fail to properly set linked tracks and Score::undoAddCR() will trigger the abort() at file segment.cpp, line 489.

Hoping this help,

M.

It maybe a different report, but when trying the steps in #7, there isn't a crash, but corruption in the linked stave: It has 3 beats, instead of 2.

Using MuseScore 2.0 Nightly Build (361ce83) - Mac 10.7.5.

Status (old) active fixed

This seems to be fixed as of 65af8f7bb9. At least, the steps in #7 no longer lead to obvious corruption. If anyone finds otherwise, please post more precise steps to reproduce!