[chuck-users] NullPointerException

Kassen signal.automatique at gmail.com
Wed Jul 4 15:15:59 EDT 2007


In a roundabout way I ran into this same thing again.

I had a array of ugens in a class, instead of home-made class-instances like
Eduard had, and adressing those from outside of the class will also yield a
nullpointer exception. Actually; even calling a member function that in turn
will adress those ugens will create a nullpointer.

Aditionally, I suspect that having a array of class-instances that in turn
each hold a array of ugens each can cause ChucK to crash outright without
warning or saving-roll, however that issue is quite hard to pinpoint as my
setup also involves a fairly large amount of sporked functions that get
sporked by other functions within this class.

It seems to me that there are definately one or more serious issues here but
they are hard define as they clearly only manifest after a sertain amount of
complexity has been reached and after that it's hard to find exactly what
combintation of factors results in nullpointers and/or crashes... I strongly
suspect something is up with sporking member functions from within classes,
though seemingly this is no major issue unless the classes are in arrays..
Unlike I previously suspected, simply sporking a awfull lot of functions
doesn't in itself crash ChucK, five digits of functions is fine, if slow
(*chough* hit enter and go make coffee *cough*).

A possible workaround (for objects) might be instantiating objects or whole
arrays outside of the classes and asigning them to instances but that would
be asking for more overhead and generally create a mess that woulds defeat
most of the purpose of using classes.

Kas.

On 6/23/07, Ge Wang <gewang at cs.princeton.edu> wrote:
>
> Dear all,
>
> Sorry for the delay (currently in Beijing) - just got a chance to
> check this and was able to reproduce the exception.  It indeed looks
> like a ChucK bug - will definitely look into this for the next release.
>
> By the way, there will be a big development round this summer
> (concurrent with some thesis fabrication) - we have a lot of new
> stuff on the move!  Stay tuned.
>
> Best,
> Ge!
>
> On Jun 9, 2007, at 7:36 PM, eduard aylon wrote:
>
> > Hi list,
> >
> > I am trying to make a list of objects where each object has
> > references to other objects, but I am not succeeding and I get a
> > NullPointerException. The piece of code below may represent what I am
> > trying to do.
> >
> > class object
> > {
> >      Std.rand2f(0., 1.) => float f_;
> > }
> >
> > class Item extends object
> > {
> >      2 => int size_;
> >      object item_[size_];
> >
> >      fun void print()
> >      {
> >          for( 0=>int i; i<size_; i++ )
> >              <<< "item [",i,"]", item_[i].f_>>>;
> >      }
> >      <<<"----------------------------------------------">>>;
> >      <<<"calling print from within class definition">>>;
> >      <<<"----------------------------------------------">>>;
> >      print();
> > }
> >
> > 4 => int n;
> > Item l[n];
> >
> > // no problems up until here
> >
> > <<<"----------------------------------------------">>>;
> > <<<"calling print from outside class definition">>>;
> > <<<"----------------------------------------------">>>;
> >
> > for( 0=>int i; i<n; i++ )
> >      l[i].print();   //offending line
> >
> >
> > After execution I get:
> > [chuck](VM): NullPointerException: shred[id=1:test.ck], PC=[37]
> >
> > Excuse me if it's too obvious, but I can't see why it rises the null
> > pointer exception. Any ideas?
> >
> > thanks in advance,
> >
> > eduard
> >
> >
> >
> > _______________________________________________
> > chuck-users mailing list
> > chuck-users at lists.cs.princeton.edu
> > https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20070704/d3d7cd74/attachment.htm 


More information about the chuck-users mailing list