-
Notifications
You must be signed in to change notification settings - Fork 757
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
Buffer and Bus validity checks and Errors #2936
Buffer and Bus validity checks and Errors #2936
Conversation
I'd prefer to catch direct use of the And I just found this --
|
I know that this solution isn't ideal. At one point, I has though about checking validity only inside the Looking at this again, I noticed some inconsistencies with how some methods and their respective |
@@ -370,6 +371,7 @@ Buffer { | |||
} | |||
|
|||
zero { arg completionMessage; | |||
if(bufnum.isNil) { Error("Cannot call % on a % that has been freed".format(thisMethod.name, this.class.name)).throw }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could simplify these. just define one method:
checkForSend {
if(bufnum.isNil) { Error("Cannot call % on a % that has been freed".format(thisMethod.name, this.class.name)).throw };
}
and then you just add the this.checkForSend
everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine as-is
The main reason why the implementation is so redundant is speed: argument passing is (relatively) slow, compared to method calls etc. And because these methods here are potential bottlenecks, they have these duplicates, like I've suggested a simplification which doesn't pass arguments. I think you could add this to the |
@patrickdupuis, you are working on an alternate version or extension of this right? |
Yes - as we discussed yesterday, I was going to improve upon this. Can we un-merge? Maybe, for now, I could simply add the same check to all the |
I'm sorry that I had misunderstood it. Can you be so kind and just make a new pull request on top? We just continue from there. |
no worries! I should have asked someone to label the PR as "Work in progess". So, I can still add to this if I push to the same branch in my fork? That's good. |
before you do more, can you try and push a little change to the same branch, and then see if github lets you make a pull request for it? |
yeah, I would recommend pushing to the same branch |
you won't be able to build on this PR, you will have to make a new one. since we have a no-force-push master, we can't undo it without also adding a revert commit. saves time just to add more on top of it. |
See #2959. I can create a new PR from this branch. Please merge this PR as soon as possible so that I can commit more changes to my branch 👍 |
Fixes #2851 (and see discussion #2846)
Some methods need to check that a Buffer/Bus is still valid before doing anything potentially destructive. The Server interprets 'nil' as zero in received messages. This means that Buffer and Bus index:0 are at risk of being modified when some methods are called on previously freed Buffers/Busses.
Hopefully, this solution is acceptable. Please review and critique away! :)