Skip to content

Exception in Tags.cs with NativeArray #11

@jhughes2112

Description

@jhughes2112
                            int t2 = graph.Dequeue();
                            GetRangesFromGraphIndex(t1, out NativeArray<int> start1, out NativeArray<int> end1);
                            GetRangesFromGraphIndex(t2, out NativeArray<int> start2, out NativeArray<int> end2);
                            NativeArray<int> startResult;
                            NativeArray<int> endResult;
                            if ((Operation)v == Operation.Or)
                            {
                                Or(start1, end1, start2, end2, out startResult, out endResult);
                            }
                            else if ((Operation)v == Operation.And)
                            {
                                And(start1, end1, start2, end2, out startResult, out endResult);
                            }
                            else // if ((Operation)v == Operation.Diff)
                            {
                                Diff(start1, end1, start2, end2, out startResult, out endResult);
                            }
                            // Enqueue results
                            startRanges.Add(startResult);
                            endRanges.Add(endResult);
                            graph.Enqueue(Tags.Length + startRanges.Count - 1);

This block can be entered such that GetRangesFromGraphIndex creates default arrays for start and end, like so:

                        start = new NativeArray<int>();
                        end = new NativeArray<int>();
                        return false;

This immediately throws an exception as soon as one of these routines tries to copy it, because these default constructed arrays are not actually allocated under the hood. This is the proper way to allocate them:

                        start = new NativeArray<int>(0, Allocator.Temp);
                        end = new NativeArray<int>(0, Allocator.Temp);
                        return false;

As always, thanks for this great project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions