Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MU4 Issue] crash/fail-assert when add measure in empty part #13291

Closed
lyrra opened this issue Sep 11, 2022 · 6 comments
Closed

[MU4 Issue] crash/fail-assert when add measure in empty part #13291

lyrra opened this issue Sep 11, 2022 · 6 comments

Comments

@lyrra
Copy link
Contributor

lyrra commented Sep 11, 2022

tested with commit: 5377cef

  1. add part and open it
  2. add measure (either start or end of score)

Assertion hit:
Assertion failed: staffEnd > staffStart && staffEnd <= _score->nstaves(), file src/engraving/libmscore/select.cpp, line 662

backtrace:

#2 0x00007ffff567540f in __assert_fail_base (fmt=0x7ffff57de128 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
assertion=0x555557a4b0d8 "staffEnd > staffStart && staffEnd <= _score->nstaves()", file=0x555557a4ae88 "src/engraving/libmscore/select.cpp", line=662,
function=) at assert.c:92
#3 0x00007ffff5684662 in __GI___assert_fail (assertion=0x555557a4b0d8 "staffEnd > staffStart && staffEnd <= _score->nstaves()",
file=0x555557a4ae88 "src/engraving/libmscore/select.cpp", line=662,
function=0x555557a4b040 "void mu::engraving::Selection::setRange(mu::engraving::Segment*, mu::engraving::Segment*, mu::engraving::staff_idx_t, mu::engraving::staff_idx_t)")
at assert.c:101
#4 0x00005555559e0724 in mu::engraving::Selection::setRange (this=0x55555f9b8430, startSegment=0x0, endSegment=0x0, staffStart=0, staffEnd=0)
at src/engraving/libmscore/select.cpp:662
#5 0x000055555596d9ae in mu::engraving::Score::selectAdd (this=0x55555f9ad340, e=0x55555f6ba650) at src/engraving/libmscore/score.cpp:3425
#6 0x000055555596d58f in mu::engraving::Score::select (this=0x55555f9ad340, e=0x55555f6ba650, type=mu::engraving::SelectType::ADD, staffIdx=0)
at src/engraving/libmscore/score.cpp:3350
#7 0x000055555640ff97 in mu::notation::NotationInteraction::doSelect (this=0x55555d378410, elements=std::vector of length 1, capacity 1 = {...}, type=mu::engraving::SelectType::ADD,
staffIndex=0) at src/notation/internal/notationinteraction.cpp:738
#8 0x000055555641fab8 in mu::notation::NotationInteraction::addBoxes (this=0x55555d378410, boxType=mu::notation::BoxType::Measure, count=1, beforeBoxIndex=-1)
at src/notation/internal/notationinteraction.cpp:3334
#9 0x000055555641f744 in mu::notation::NotationInteraction::addBoxes (this=0x55555d378410, boxType=mu::notation::BoxType::Measure, count=1,
target=mu::notation::AddBoxesTarget::AtEndOfScore) at src/notation/internal/notationinteraction.cpp:3292
#10 0x0000555556405f93 in mu::notation::NotationActionController::addBoxes (this=0x555558b7b640, boxType=mu::notation::BoxType::Measure, count=1,
target=mu::notation::AddBoxesTarget::AtEndOfScore) at src/notation/internal/notationactioncontroller.cpp:1369
#11 0x0000555556405da3 in mu::notation::NotationActionController::addMeasures (this=0x555558b7b640, actionData=..., target=mu::notation::AddBoxesTarget::AtEndOfScore)
at src/notation/internal/notationactioncontroller.cpp:1358

@HemantAntony
Copy link
Contributor

HemantAntony commented Sep 11, 2022

Damn it :)

@HemantAntony
Copy link
Contributor

@lyrra I don't think that the linked commit is the one at fault. I just reverted it and the crash still occurs

@lyrra
Copy link
Contributor Author

lyrra commented Sep 11, 2022

@lyrra I don't think that the linked commit is the one at fault. I just reverted it and the crash still occurs

My bad, I meant what commit that was used for test.

@HemantAntony
Copy link
Contributor

Ah no worries! Also its really really helpful if you follow the issue templates. Also it would be great if you could put the backtrace in a dropdown so as to not make issues long and hard to read for team members. Last thing, can you change the title to 'Crash when you add measure in empty part' :)

@lyrra lyrra changed the title [MU4 Issue] add measure in empty part [MU4 Issue] crash/fail-assert when add measure in empty part Sep 11, 2022
@wizofaus
Copy link
Contributor

wizofaus commented Sep 12, 2022

Reproducing this is easy enough and it's not hard to see why it happens, the question is what the correct behaviour is - logically you can't add measures if a score has no staves, even if it did anything you wouldn't see the result in the current part score...v3 doesn't appear to even allow "empty" parts so it's not an issue there.

The fix I tried that worked was to modify Selection::updateSelectedElements() to return early if startSegment() returned NULL, viz.:

     if (_state != SelState::RANGE || !startSegment()) {
         update();
         return;
     }

But that just makes it look like the command does nothing (actually it does work, and you can see it on the full score or other parts that actually have instruments assigned).

@wizofaus
Copy link
Contributor

wizofaus commented Sep 12, 2022

#13298 should fix the crash at least

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants