Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECMA-335 addendum should mention that null managed pointers are legal #69690

Closed
GrabYourPitchforks opened this issue May 23, 2022 · 1 comment · Fixed by #71794
Closed

ECMA-335 addendum should mention that null managed pointers are legal #69690

GrabYourPitchforks opened this issue May 23, 2022 · 1 comment · Fixed by #71794
Labels
area-VM-coreclr documentation Documentation bug or enhancement, does not impact product or test code
Milestone

Comments

@GrabYourPitchforks
Copy link
Member

Ref: https://github.com/dotnet/runtime/blob/main/docs/design/specs/Ecma-335-Augments.md

We expose APIs like Unsafe.IsNullRef and Unsafe.NullRef, which imply that nullptr managed pointers are supported across our runtimes. However, ECMA-335, Sec. II.14.4.2 and III.1.1.5.2 both explicitly state that nullptr managed pointers are disallowed. ECMA should be updated.

@GrabYourPitchforks GrabYourPitchforks added documentation Documentation bug or enhancement, does not impact product or test code area-VM-coreclr labels May 23, 2022
@ghost ghost added the untriaged New issue has not been triaged by the area owner label May 23, 2022
@GrabYourPitchforks
Copy link
Member Author

Additional note: we might want to point out that managed pointers just past the end of managed objects are legal. ECMA today only says managed pointers just past the end of managed arrays are legal. As fixed buffers take off, we might have more occurrences of people treating non-array objects as array-like.

@trylek trylek removed the untriaged New issue has not been triaged by the area owner label Jun 20, 2022
@trylek trylek added this to the 7.0.0 milestone Jun 20, 2022
davidwrighton added a commit to davidwrighton/runtime that referenced this issue Jul 7, 2022
- Declare that it is valid to have a null managed pointer, but declare it invalid to actually read from such a pointer
  - In practice this has always been legal, as it has been legal to managed pointer locals for years, and they are included in the list of values that are zeroinitialized on method start
- Also clarify the rules to permit a managed pointer to the location directly following a managed object.
  - This is a new capability in the spec that will likely be useful for accessing fixed size data buffers held in objects of the GC heap. However, the GC has been able to tolerate this behavior for many years, so there is no code change necessary.

Fixes dotnet#69690
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 7, 2022
jkotas added a commit that referenced this issue Aug 2, 2022
* Describe the validity of null managed pointers
- Declare that it is valid to have a null managed pointer, but declare it invalid to actually read from such a pointer
  - In practice this has always been legal, as it has been legal to managed pointer locals for years, and they are included in the list of values that are zeroinitialized on method start
- Also clarify the rules to permit a managed pointer to the location directly following a managed object.
  - This is a new capability in the spec that will likely be useful for accessing fixed size data buffers held in objects of the GC heap. However, the GC has been able to tolerate this behavior for many years, so there is no code change necessary.

Fixes #69690

Co-authored-by: Jan Kotas <[email protected]>
Co-authored-by: Aaron Robinson <[email protected]>
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 2, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-VM-coreclr documentation Documentation bug or enhancement, does not impact product or test code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants