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
- On Script import/reimport MonoImporter does not generate consistent results due to updating Custom packages
- [Entities Graphics] Size of the Content Update generated folder increases when changes are made to the Scene
- In Play Mode, an extra Sync Call is made every frame when a GameObject has a Rigidbody 2D component
- Crash on block_remove when a scene is opened in a specific project
- The GameObject with a Hinge Joint Component does not return to the initial position when the Use Motor property is toggled off
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(...).