'new' running fine in Mac/Windows player but crashes in iPhone player

A simple ‘new’ statement is crashing on iPad2 with iOS-5, but the same code works fine on Mac/Windows player builds.

Xcode 4.2 on MacOSX 10.6, gdb outputs: “compute_class_bitmap: Invalid type 13 for field GraphNode`1[T]:data”

Below is the details of the object i am creating.

//A generic base class for graph node
//
public class GraphNode<T> {
  //ctor 
    public GraphNode(string nodeId, T data) {
        this.Id = nodeId;
        this.data = data;
    }

  ...

  //fields
    string Id;
    T data;
    List< GraphNode<T> > neighbors = new List< GraphNode<T> >();
    ...
}

public class Puzzle {
    public class Checkpoint {
      ...
    }

    //A graph of some checkpoints
    //
    public class CheckpointsGraphNode : GraphNode<Checkpoint> {
      //ctor
        public CheckpointsGraphNode(string chkptId, Checkpoint chkpt) : base(chkptId, chkpt) {
            ...
        }

        ...
    }

    ...
}

...

...

Puzzle.CheckpointsGraphNode node = new Puzzle.CheckpointsGraphNode(nodeId, chkpt);
                                      //
                                      //The program crashes here on iPad
                                      // at runtime with error "compute_class_bitmap: Invalid type 13 for field GraphNode`1[T]:d"
...

Can anybody please help me out? I believe this is some trivial problem, but im unable to solve it. This is my first project with unity and also C#. I come from C/C++ background.

I am using .NET subset Api compatibility level and Unity iOS.

AOT does not allow such ‘generic of generic’ datastructures in a general form if I recall right so the solution is not to do use generic of generic but make the nested one one with an effective class instead of the generic T

anything but iOS, X360 and PS3 use JIT, not AOT, thats why its no problem on win - osx.

Ouch. Thanks a lot. It worked! :slight_smile:

Where can we learn more about these rules?

The only reference that mentions anything on AOT limitations in general are on the MonoTouch page (unity does not use nor support it, but AOT has generally the same limitation) at least to my knowledge. You can find it on Limitations of Xamarin.iOS - Xamarin | Microsoft Learn

Generally AOT is not the ‘standard’ in .NET even less in Mono, its the exception for obvious reasons (only embedded and limited platforms can use it without sacrificing lots of performance from JIT optimizations)

I know about it due to the preorder beta on Unity 3 where it was first talked about it.

I’ve just started running into this and wow does it castrate the power of generics.

…and of course I notice that it isn’t listed as an issue for the current version of Mono.