Search Issue Tracker
By Design
Votes
0
Found in [Package]
0.16.0-preview.21
Issue ID
1305745
Regression
No
Assigning pointer of unsafe pointer throws InvalidOperationException even though [NativeDisableUnsafePtrRestriction] is used
How to reproduce:
1. Open the user's attached project ("DotsMan.zip")
2. Enter Play mode
3. Notice the "InvalidOperationException: OnUpdate_LambdaJob0.JobData.testPtr uses unsafe Pointers" error constantly thrown
Expected results: "InvalidOperationException: OnUpdate_LambdaJob0.JobData.testPtr uses unsafe Pointers" error is not thrown, because [NativeDisableUnsafePtrRestriction] is used
Actual results: "InvalidOperationException: OnUpdate_LambdaJob0.JobData.testPtr uses unsafe Pointers" error is thrown even though [NativeDisableUnsafePtrRestriction] is used
Reproducible with: ECS 0.14.0-preview.19, 0.16.0-preview.21 (2020.2.3f1, 2021.1.0b3, 2021.2.0a3)
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
- ScrollView speed is slower when entering Play mode
- UI Builder elements disappear and "Semantic - Unknown template name" error appears when changes to "Template" parameter are saved
- Renderers outside Light Probe hull use incorrect Ambient Probe values when "Renderer Light Probe Selection" is set to "Use Ambient Probe" and "Light Probes" on Mesh is set to "Blend Probes"
- ArgumentNullException error occurs when selecting a Camera in the Hierarchy with the Scene view open
- Clicking 'Open Editor Log' through the Console fails to open redirected Logs when relative Log files exist outside of the Project root
Resolution Note:
This works as intended. The problem is that [NativeDisableUnsafePtrRestriction] should only be applied to members of a job-struct, not to members of a system. Line 121 causes the Entities.ForEach to capture the local variable testPtr declared on line 102. This will cause the problem. Instead of applying the attribute to the member of the system, you must use Entities.WithNativeDisableUnsafePtrRestriction(testPtr).ForEach(...).