segmentation fault on function call
Hello, The following crashes ChucK $ chuck --version chuck version: 1.3.2.0-beta-1 (chimera) mac os x : intel : 64-bit http://chuck.cs.princeton.edu/ http://chuck.stanford.edu/ funCrash.ck: class Foo { 1.0 => float _f; fun float foo(float f) { f => _f; return _f; } } Foo f; 42.0 => f.foo; <<<"foo", f.foo>>>; $ chuck funCrash.ck Segmentation fault: 11 Both the write and read are necessary to make ChucK crash. michael
On Mon, Jan 28, 2013 at 04:48:11PM -0600, Michael Heuer wrote:
Hello,
The following crashes ChucK
$ chuck --version
chuck version: 1.3.2.0-beta-1 (chimera) mac os x : intel : 64-bit http://chuck.cs.princeton.edu/ http://chuck.stanford.edu/
funCrash.ck: class Foo { 1.0 => float _f;
fun float foo(float f) { f => _f; return _f; } }
Foo f; 42.0 => f.foo; <<<"foo", f.foo>>>;
$ chuck funCrash.ck Segmentation fault: 11
Both the write and read are necessary to make ChucK crash.
This is odd. The "read", as you call it, should IMHO be a syntax error at best; you seem to mean to refer to f._f there, to read, Not the "foo" function which should really be called "foo()" and isn't overloaded to deal with 0 arguments. At best calling f.foo should give the memory address of the function. It is a bug though, as your code should under no condition except for Machine.crash() crash the machine. Should, I said ;-). Some editions ago we seem to have run into what I suspect is a error handler bug; things that used to be plain errors now instead crash the whole vm. Not good as that makes livecoding in ChucK a bit too dangerous, IMHO. Anyway, I have no idea why the write would matter unless it is related to the unused return value of the function. I seem to remember somebody (Spencer?) commenting a long time ago how those would somehow end up on the stack, I thought that had been dealt with (as it should be, nowhere in the docs does anything imply you need to use return values and the stack is not something end-users should run into anyway). So; BUG, and a nice data-point that might help explain what is going so terribly wrong in the error handler (unless my gut-feeling is wrong and it might indicate something else). Congratulations on your catch. Yours, Kas.
Kassen
On Mon, Jan 28, 2013 at 04:48:11PM -0600, Michael Heuer wrote:
Hello,
The following crashes ChucK
$ chuck --version
chuck version: 1.3.2.0-beta-1 (chimera) mac os x : intel : 64-bit http://chuck.cs.princeton.edu/ http://chuck.stanford.edu/
funCrash.ck: class Foo { 1.0 => float _f;
fun float foo(float f) { f => _f; return _f; } }
Foo f; 42.0 => f.foo; <<<"foo", f.foo>>>;
$ chuck funCrash.ck Segmentation fault: 11
Both the write and read are necessary to make ChucK crash.
This is odd. The "read", as you call it, should IMHO be a syntax error at best; you seem to mean to refer to f._f there, to read, Not the "foo" function which should really be called "foo()" and isn't overloaded to deal with 0 arguments. At best calling f.foo should give the memory address of the function.
Yes, odd. That pattern is my best attempt to make classes/chugens/chubgraphs look more UGen-ly, in that you can use value => foo notation and f.foo(value) notation. Typically in my use cases there are side effects in the function call in addition to setting the value of the field, so just doing value => f._f in the example above would not be sufficient. For example, this method sets a bunch of stuff https://github.com/heuermh/lick/blob/master/Mesmerizer.ck#L143
It is a bug though, as your code should under no condition except for Machine.crash() crash the machine. Should, I said ;-). Some editions ago we seem to have run into what I suspect is a error handler bug; things that used to be plain errors now instead crash the whole vm. Not good as that makes livecoding in ChucK a bit too dangerous, IMHO.
Anyway, I have no idea why the write would matter unless it is related to the unused return value of the function. I seem to remember somebody (Spencer?) commenting a long time ago how those would somehow end up on the stack, I thought that had been dealt with (as it should be, nowhere in the docs does anything imply you need to use return values and the stack is not something end-users should run into anyway).
So; BUG, and a nice data-point that might help explain what is going so terribly wrong in the error handler (unless my gut-feeling is wrong and it might indicate something else). Congratulations on your catch.
Thanks. If you're not breaking ChucK or blowing up a channel on your mixer occasionally, you're not trying hard enough. :) michael
On Mon, Jan 28, 2013 at 05:22:15PM -0600, Michael Heuer wrote:
Yes, odd.
That pattern is my best attempt to make classes/chugens/chubgraphs look more UGen-ly, in that you can use value => foo notation and f.foo(value) notation. Typically in my use cases there are side effects in the function call in addition to setting the value of the field, so just doing value => f._f in the example above would not be sufficient.
Yes got it. In a way this is a inconsistency; 3 => my_gain.gain; //works 3 => my_class_instance.funny(); //has to be done like that. I agree with you that this is inconsistent to the point where it might bother us. I'd go as far as claiming that the "=>" operator is already so overloaded that the only way to make sure ChucK will stay consistent is to also allow for user-defined further overloading. I can see why serious CS people might hide under the nearest furniture over this idea, but I'm sticking to it.
Thanks. If you're not breaking ChucK or blowing up a channel on your mixer occasionally, you're not trying hard enough. :)
IMHO mixer channels on mixers beyond the "bargain" level should not blow either, at least not when fed signals somewhat similar to reasonable audio ones. Mistakes in code and patching can and will happen. We expect error handlers and mixers to deal with those; I expect the pre-fader listen function to tell me when I patched something wrong *before* I open the fader and risk damaging a rack of amps, stack of speakers and potentially the ears of a few hundred people; that's what the mixer is for, aside from mixing and routing. Same thing with a error-handler. Error-handlers should be able to take abuse, that is what they are there for. Before we are at that level we clearly need to go through this phase where any advanced ChucK project will yield bug-reports and we need the kind of ChucKist like yourself who'll file them. :-) Yours, Kas.
Howdy,
I think what you are going for is this?
class Foo
{
1.0 => float _f;
fun float foo(float f)
{
f => _f;
return _f;
}
fun float foo()
{
return _f;
}
}
Foo f;
42.0 => f.foo;
<<<"foo", f.foo()>>>;
The canonical ChucK setter/getter paradigm is two functions, one each for
setting and getting. This is more or less uniformly adhered to by the
built-in ugens. Calling f.foo (without parentheses), if foo is a function,
is fairly atypical, since it evaluates to an internal memory address that
doesn't have much significance at the ChucK code level. That being said,
atypical use cases still should not be met with a crash, so thanks for
bringing this up!
spencer
On Mon, Jan 28, 2013 at 3:50 PM, Kassen
On Mon, Jan 28, 2013 at 05:22:15PM -0600, Michael Heuer wrote:
Yes, odd.
That pattern is my best attempt to make classes/chugens/chubgraphs look more UGen-ly, in that you can use value => foo notation and f.foo(value) notation. Typically in my use cases there are side effects in the function call in addition to setting the value of the field, so just doing value => f._f in the example above would not be sufficient.
Yes got it. In a way this is a inconsistency; 3 => my_gain.gain; //works 3 => my_class_instance.funny(); //has to be done like that.
I agree with you that this is inconsistent to the point where it might bother us. I'd go as far as claiming that the "=>" operator is already so overloaded that the only way to make sure ChucK will stay consistent is to also allow for user-defined further overloading. I can see why serious CS people might hide under the nearest furniture over this idea, but I'm sticking to it.
Thanks. If you're not breaking ChucK or blowing up a channel on your mixer occasionally, you're not trying hard enough. :)
IMHO mixer channels on mixers beyond the "bargain" level should not blow either, at least not when fed signals somewhat similar to reasonable audio ones. Mistakes in code and patching can and will happen. We expect error handlers and mixers to deal with those; I expect the pre-fader listen function to tell me when I patched something wrong *before* I open the fader and risk damaging a rack of amps, stack of speakers and potentially the ears of a few hundred people; that's what the mixer is for, aside from mixing and routing. Same thing with a error-handler. Error-handlers should be able to take abuse, that is what they are there for.
Before we are at that level we clearly need to go through this phase where any advanced ChucK project will yield bug-reports and we need the kind of ChucKist like yourself who'll file them. :-)
Yours, Kas. _______________________________________________ chuck-dev mailing list chuck-dev@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev
participants (3)
-
Kassen
-
Michael Heuer
-
Spencer Salazar