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
- UI Source Image property gets set to 'None' when using a specific Sprite and Play mode is entered
- Rendering locks up when not looking at a transparent material on Meta Quest 2
- Volumetrics break when using a Custom Pass to create a Thickness Buffer for Alpha Clipping
- All tests are run instead of only the failed ones when the "Rerun Failed" button is pressed
- GameObject is not masked when the "Render PostProcessing Effects" pass executes with a resolved non-MSAA Color target and MSAA DepthStencil target
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.