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
- The Editor freezes on RenderGraphViewer.Repaint when entering too many characters in search fields without character limits
- Adding a new SubLayer in Graphics Compositor renders BaseLayer darker and makes it flicker
- DOTS Materials Not Rendering in Player When Using Entity Graphics with Custom SRP
- Sprite Pivot position in Sprite Editor and Scene View do not match when the position is custom
- [HDRP] Unchecking the "Base layer" in Graphics Compositor results in Camera view rendering over the window
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(...).