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

sclang: MIDI realtime messages: Push correct number of values onto the stack #5200

Merged
merged 1 commit into from
Nov 20, 2020

Conversation

jamshark70
Copy link
Contributor

Purpose and Motivation

Fixes #5199 (well... pending testing... I don't have a Windows build environment so the changes here are not tested).

MIDI system real-time messages should perform a method call like MIDIIn.doSysrtAction(code, data) -- internally, this means four items go onto the stack: the receiver, method selector and two arguments.

SC_PortMIDI.cpp currently pushes three items onto the stack (receiver, method selector, and a data value without the message type number) -- but then specifies four stack values to be processed. Because one of those stack entries doesn't exist, it segfaults.

I'm not able to test in Windows.

I discovered this by accidentally replicating the crash in Linux (by deleting the message type argument, without changing the number of stack entries). I'm fairly confident but somebody needs to build it and try it.

Types of changes

  • Bug fix

To-do list

  • Code is tested
  • All tests are passing
  • This PR is ready for review

@jamshark70 jamshark70 added bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. comp: sclang sclang C++ implementation (primitives, etc.). for changes to class lib use "comp: class library" os: Windows crash things which cause a crash in the interpreter, servers, or IDE. do not use for PRs labels Oct 17, 2020
@jamshark70
Copy link
Contributor Author

Side note: It also appears, from SC_CoreMIDI.cpp, that the dataless real-time messages could be simplified by eliminating the data argument.

CoreMIDI:

    case 6: // tunerequest
    case 8: // clock
    case 9: // tick
    case 10: // start
    case 11: // continue
    case 12: // stop
    case 14: // activeSense
    case 15: // reset
        gRunningStatus = 0; // clear running status
        runInterpreter(g, s_midiSysrtAction, 3);
        return 1;

PortMIDI:

        case 0xF6:
        case 0xF8:
        case 0xF9:
        case 0xFA:
        case 0xFB:
        case 0xFC:
        case 0xFE:
            gRunningStatus = 0; // clear running status
            ++g->sp;
            SetInt(g->sp, p[i] & 0xF);
            ++g->sp;  // could delete this line
            SetInt(g->sp, 0);  // could delete this line
            runInterpreter(g, s_midiSysrtAction, 4);  // change to '3' here
            i++;
            break;

But perhaps not in this PR.

@mossheim mossheim removed bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. crash things which cause a crash in the interpreter, servers, or IDE. do not use for PRs labels Oct 23, 2020
@jamshark70
Copy link
Contributor Author

I'd like to ask what is the path forward on this PR.

I believe it will fix a crashing bug. I assumed that because a crash is involved, it would be treated with higher priority... but the "crash" label was removed so there is now no way to tell from the PR list that this is about a crash... so it's been lost in the shuffle.

Should I push the branch directly to this repository for it to be built automatically? I can reproduce the crash but I don't have a Windows build environment.

@mossheim
Copy link
Contributor

but the "crash" label was removed so there is now no way to tell from the PR list that this is about a crash... so it's been lost in the shuffle.

@jamshark70 are you asking why i removed the label? it's because we typically don't use "bug" or "crash" for PRs, only issues. i regularly make changes like this to labels on PRs and issues as part of triageing. we can definitely change this practice, if you'd like.

@mossheim
Copy link
Contributor

I'd like to ask what is the path forward on this PR.

someone will review it when they have time, like any other PR.

@jamshark70
Copy link
Contributor Author

it's because we typically don't use "bug" or "crash" for PRs, only issues

I thought it might be something like that.

"Bug," I suppose, is not really necessary for a PR. As for the crash label, my lens is tinted by my time in a software company, where all crashes automatically received top priority to be fixed in the next release. So I was surprised that this issue dropped off the radar. (Admittedly, I didn't follow it carefully either, so I take my share of the responsibility for that.) Labeling crashes might help bring them to the top.

True, this issue affects seldom used MIDI messages on one OS only -- but it was reported by a user, who is unable to proceed with syncing SC to hardware. There's no workaround.

By "path forward," I specifically meant generating a test build. The code looks correct but shouldn't be merged until I fire the offending messages at it and it responds correctly.

@mossheim
Copy link
Contributor

mossheim commented Nov 14, 2020

As for the crash label, my lens is tinted by my time in a software company, where all crashes automatically received top priority to be fixed in the next release. So I was surprised that this issue dropped off the radar. (Admittedly, I didn't follow it carefully either, so I take my share of the responsibility for that.) Labeling crashes might help bring them to the top.

prioritizing based only on crash/noncrash is not so productive, because many crashes happen under uncommon circumstances and shouldn't receive attention just for that. if your gripe is that we should be doing a better job of prioritizing issues and PRs, i agree, and we've been discussing this on the dev calls. i'll open a ticket after the 3.11.2 release to explain more.

By "path forward," I specifically meant generating a test build. The code looks correct but shouldn't be merged until I fire the offending messages at it and it responds correctly.

oh, that's much clearer thanks. the wiki has instructions on how to do that: https://github.com/supercollider/supercollider/wiki/Continuous-Integration---Travis-&-Appveyor#storage-and-deployment-of-build-artifacts

@jamshark70
Copy link
Contributor Author

"Gripe" is a strong word, and not my intent at all.

I do think this PR in particular is an ideal candidate for a patch release: small scope, doesn't break anything that was working (because it was fundamentally not working), and the symptom is severe. Given that, when I saw 3.11.2 being discussed, I should have spoken up, and I didn't -- so I don't have any grounds to complain about other people's handling. It surprised me that it didn't happen, but the lesson learned is that I shouldn't assume, not that other people should read my mind.

I still hold the opinion that it's useful in the PR list to be able to see at a glance the difference between bug fixes and enhancements (bug fixes are often more urgent than new features), and whether it's related to a crash or not. When evaluating PRs for inclusion in a release, you're looking at the PR list, not the issue list. I don't see a compelling reason to keep this information at one remove. But I haven't been maintaining the list myself, so I'll only offer it as an opinion and not press the point.

@mossheim
Copy link
Contributor

"Gripe" is a strong word, and not my intent at all.

i didn't realize it would read as strong, my apologies.

we'll have a more appropriate ticket to discuss this soon. i'll try to make sure your concerns are addressed.

@mossheim mossheim mentioned this pull request Nov 17, 2020
@mossheim mossheim added this to the 3.12.0 milestone Nov 18, 2020
@jamshark70
Copy link
Contributor Author

Picking up again:

https://github.com/supercollider/supercollider/wiki/Continuous-Integration---Travis-&-Appveyor#storage-and-deployment-of-build-artifacts: "on every build of an internal branch, a ZIP macOS archive and ZIP Windows archives are deployed to S3, and (normally) the Windows archives are stored on AppVeyor too"

Just to doublecheck/confirm: Is it OK if I push this branch directly to this repo, to generate a test build? Not normal practice, so I wanted to ask before going ahead with that.

Thanks!

@mossheim
Copy link
Contributor

Is it OK if I push this branch directly to this repo, to generate a test build? Not normal practice, so I wanted to ask before going ahead with that.

yes, definitely ok!

@jamshark70
Copy link
Contributor Author

jamshark70 commented Nov 19, 2020

Using the test build from s3, the fix seems OK.

  • No crash!
  • Sysrt messages are routed to the proper receiving functions.
  • Active sensing appeared not to be received at all. However, the sysrt function wasn't called either -- so it looks to me like loopMIDI simply doesn't transmit active sensing messages.

In that case, we could probably go ahead and merge.

Actually, the arguments passed through to the rt responder functions might not make sense. I'd like to doublecheck that first.

@jamshark70
Copy link
Contributor Author

Actually, the arguments passed through to the rt responder functions might not make sense. I'd like to doublecheck that first.

The argument does make sense: It's the device ID (which is relevant).

So I'm pretty well satisfied. I think it's OK to review.

Copy link
Contributor

@mossheim mossheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@mossheim mossheim merged commit 564255d into supercollider:develop Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: sclang sclang C++ implementation (primitives, etc.). for changes to class lib use "comp: class library" os: Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Windows sclang crashes upon MIDI MTC quarter frame, song position, song select messages
2 participants