Using MIDI input to input chords causes crash
MuseScore crashes upon the following action:
- Input two or more notes at the same time with my MIDI input device.
The program crashed without fail. It is not a random encounter.
Information:
OS: Windows 7
Build: MuseScoreNightly-2012-08-18
MIDI input device: Roland FP-7
The device works perfectly with the stable 1.2 release.
Comments
Thanks for your report :).
Linked with #16954: shift-<note> does not add note to chord just entered
This bug is still active, note input over midi interface causes crash when you enter more than one note at once.
win7x64 musescore fdd8040
I'm having a similar issue with the same MIDI device (Roland FP-7) on Linux (Ubuntu 12.10 64-bit). Version 1.2 allowed me to use the piano for MINI input, with current trunk I cannot enter any notes using the piano.
If necessary I can do a `git bisect` for this issue.
Any updates on that front? I am finally able to input MIDI, and I'm experiencing the crashes reported here. Below is the gdb backtrace of the crash after holding a C and then entering an E on the piano. The crash occurs as soon as E is pressed (while holding C). Ubuntu 12.10 amd64, latest packages, revision 1778f37b61.
Looks to me like a simple "null pointer" exception.
Hi, I've looked into this some days ago.
I think I found a potential fix for the problem, but I did the experiments on a bulk source directory.
I have to properly set up the developer environment before posting the fix here.
I guess I'll have some spare time in the next weekend, so please wait a little bit.
Bye
As far as I understand the problem, the reason is that the check
in libmscore/cmd.cpp:382 (Score::addPitch) fails, which leads to a premature "return 0" in the following line. The returned "0" later causes the trouble. I have checked _is.cr()->type(), it returns Element::REST (value: 17). Just a wild guess: Perhaps moveToNextInputPos() (lines 387 and 447 in the same file/routine) should be called before adding the pitch, and not after?
By the way, are there automated tests for MIDI input in the project?
Added pull request for bugfix: https://github.com/musescore/MuseScore/pull/166
I took a different path to fix this: https://github.com/musescore/MuseScore/pull/167 - it works here, however this is the first time I look into the sources, so comments are really welcome :)
watery: This is much simpler than my hack, I'd vote for implementing your solution.
My other commit is still valuable: Safeguarding the GUI against further occasions where addNote might return 0. Could you add that to your pull request?
Thank you :)
About your proposal, I'm not sure about it, because I can't tell if by design addNote() is expected to never return 0 - which would make a check on its return value useless, except, of course, in case of a bug; but in the latter case this could hold for almost every other place in the source, so that change should be more, say, structural.
I'll leave a message to lasconic about that.
I'm setting this back to active as in my fix sometimes chords aren't properly handled and their notes are inserted separately.
Well, I'm having troubles reproducing my own issue :) what basically happens is that when reiterating:
After a while the chords are detected but splitted in separate notes.
It seems so random that I'm starting to think it could be due to my digital piano not sending MIDI messages always correctly.
Anyway with my fix I didn't got any more crash, so this could be turned into "normal".
If a bug isn't reproducible, it would be better to close the issue for it and file a separate one for others :).
I agree, but I'd like to investigate if the bug is caused by my fix, or is my fix that is making it visible.
Since I can't reproduce the problem, I can't debug it, and I'm no more willing to submit the fix.
Anyway, I wrote everything here so that a more experienced developer can add some suggestions or take the proper decision :)
You can leave it open if you want - someone else might be able to reproduce?
Fixed in 9e27b5ad4b
Now both pull requests got merged, don't they conflict with one another? At least their change to libmscore/cmd.c in the 1st hunk of the patches?
I saw it just now... I can't say anything code-wise (I'll see when I have got some spare time), but from a logical point of view I guess they could, as we both tried to fix the same issue with two different approaches.
And they do :)
in 9e27... build you can enter chords with midi input without a crash but the behavior is just weird.
Entering more than one note with the midi-keyboard adds them randomly elsewhere in the score, not vertically but horizontally.
Thank you zephyrus for your test.
I left a comment on my pull request.
In reply to post 22: Yes they do. I have posted a comment to #166.
Have added a pull request to undo my conflicting changes: #182.
i cannot reproduce any problems
Automatically closed -- issue fixed for 2 weeks with no activity.