Search Issue Tracker
Fixed
Fixed in 6.4.0
Votes
0
Found in
6.4.0
2.6.2
Issue ID
UUM-124997
Regression
No
InvalidOperationException error or crash when allocating a large NativeParallelHashSet
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:
{noformat}0x00007FFBB304C68E (Unity) memcpy
0x00007FFBAF83FC11 (Unity) UnsafeUtility_CUSTOM_MemCpy
0x000001CBA100FD88 (Mono JIT Code) (wrapper managed-to-native) Unity.Collections.LowLevel.Unsafe.UnsafeUtility:MemCpy (void,void,long)
0x000001CC6D4E2B5B (Mono JIT Code) [.\Library\PackageCache\com.unity.collections\Unity.Collections\UnsafeParallelHashMap.cs:175] Unity.Collections.LowLevel.Unsafe.UnsafeParallelHashMapData:ReallocateHashMap<short3, bool> (Unity.Collections.LowLevel.Unsafe.UnsafeParallelHashMapData*,int,int,Unity.Collections.AllocatorManager/AllocatorHandle)
0x000001CC6D4E2953 (Mono JIT Code) [.\Library\PackageCache\com.unity.collections\Unity.Collections\UnsafeParallelHashMap.cs:1196] Unity.Collections.LowLevel.Unsafe.UnsafeParallelHashMap`2<short3, bool>:set_Capacity (int)
0x000001CC6D4E2893 (Mono JIT Code) [.\Library\PackageCache\com.unity.collections\Unity.Collections\NativeParallelHashMap.cs:169] Unity.Collections.NativeParallelHashMap`2<short3, bool>:set_Capacity (int)
0x000001CC6D4E2763 (Mono JIT Code) [.\Library\PackageCache\com.unity.collections\Unity.Collections\NativeParallelHashSet.cs:71] Unity.Collections.NativeParallelHashSet`1<short3>:set_Capacity (int) {noformat}
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- An "RefreshInternalV2 is called before InitialRefresh" error is thrown when opening a project where a build profile with Player settings added is selected
- MeshCollider preview gizmo disappears from the Scene view when overriding the mesh asset using any 3D editing tool
- Tutorial project is not created when started from the Get set up tab
- Audio Listener Component expands when selected
- [iOS] Frame Debugger rendering output doesn't work with iOS builds
Resolution Note:
The fix has been backported to version 6000.4.2f1
Resolution Note (fix version 6.4.0):
The 6000.4 backport has landed and is available as of version 6000.4.2f1
Resolution Note (fix version 6.4.0):
The fix has been backported to version 6000.4.2f1