Search Issue Tracker
By Design
Votes
0
Found in [Package]
1.8.2
Issue ID
BUR-2142
Regression
No
NativeHashSet Capacity Accessor triggers exception when scheduled for jobs
Steps to reproduce:
1. Open the attached user's project "JobsTest.zip"
2. Open the "SampleScene.unity"
3. Enter Play Mode
4. Observe the Console window
Expected results: NativeHashSet Capacity Accessor does not trigger an exception when scheduled for jobs
Actual results: NativeHashSet Capacity Accessor triggers an exception when scheduled for jobs
Reproducible on: Burst 1.6.6 - 1.8.2 (2020.3.41f1, 2021.3.15f1, 2022.2.1f1, 2023.1.0a23)
Notes:
-Exception outputted:
InvalidOperationException: The previously scheduled job JobDependencyTest:GenerateIndices writes to the Unity.Collections.NativeHashSet`1[System.Int32] GenerateIndices.output.m_Data. You must call JobHandle.Complete() on the job JobDependencyTest:GenerateIndices, before you can deallocate the Unity.Collections.NativeHashSet`1[System.Int32] safely.
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckDeallocateAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <bae255e3e08e46f7bc2fbd23dde96338>:0)
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
- GPU utilization increases by 20% on Meta Quest headsets when Render Graph is enabled on 6000.0.16f1 and higher
- Value on Slider (Int) control in UI Builder displays as default when saving UI Document
- Color mismatch in UI Builders Library panel when the Editors theme is set to Light Mode
- [Android ] "AndroidJNI.ToBooleanArray" returns a random non-zero value instead of "IntPtr.Zero" when the method argument is null
- Non-HDR color picker opens when selecting material color with HDR enabled
Resolution Note:
This isn't a Burst bug, because the same thing happens with Burst disabled. And also, I don't think there's a bug here. The error message says correctly that you must call JobHandle.Complete() before disposing the output data used in the job. And I think the user was aware of this, because the sample project contains a commented-out line that does the correct thing: generatorHandles[0].Complete();.
Note that you must call Complete before accessing the NativeHashSet Capacity, because the job system has detected that the NativeHashSet is used in the job, so it's only safe to access it after the job has completed.