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
- [Dragon Crashers] Build fails in U6
- [Dragon Crashers] 4 Shader error messages on import
- [Dragon Crashers] Readme text is white on light grey
- Cursor stays in front of the first character when entering text in the TextMeshPro field
- Searching in Hierarchy causes unwanted component calls
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(...).