Reproduction steps:
1. Open the attached project "Project"
2. Attach “Assets/OverflowTest.cs“ to “MainCamera” GameObject
3. Enter the Play mode
4. Observe the console
Expected result: HashSet is created and memory is allocated for it
Actual result: InvalidOperation error is thrown or Editor crashes if the size is increased
Reproducible with: 2.4.2 (2022.3.39f1, 6000.0.12f1)
Couldn’t test with: 1.2.4 (2021.3.40f1) - (error CS0246: The type or namespace name 'NativeParallelHashSet<>' could not be found )
Reproducible on: Windows 10
Not reproducible on: No other environment tested
Notes:
Crashes when allocating a larger HashSet (double the initial capacity in OverflowTest.cs to reproduce the crash)
Calculations in the CalculateDataSize function in UnsafeParallelHashMap.cs appear to hit the integer limit which causes a negative value to be returned, changing var to long resolves the error, this can be seen in the “ProjectWithEditedHashSet“ project, the crash still occurs with the increased size though
First few lines of stack trace: