Search Issue Tracker
By Design
By Design in 1.8.X
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
- Texture Import Warnings are obscured by other Terrain Layer options in the Inspector
- Active Targets section text in Graph Inspector is truncated despite available space
- Burst Inspector middle divider is jittering when resized with the Burst Inspector window docked
- Shader Graph Node information is briefly displayed in Graph Inspector when clicking on Category in the Blackboard
- JsonConvert conversion fails trying to call GetCallbackMethodsForType when [OnDeserialized] is used in a class
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.
Resolution Note (1.8.X):
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.