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

Package: Entity Component System (ECS)

-

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)

  1. 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(...).

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.