Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Describe the validity of null managed pointers #71794
Describe the validity of null managed pointers #71794
Changes from 1 commit
b3b6174
636b7ea
9ff3f4d
4cc1fa0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the significance of "Managed pointers shall be reported to the garbage collector even if they do not point to managed memory."? It feels like a internal implementation detail that does not need to be in the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I think we should strike the entire sentence. It is in section II.14.4.2 Managed pointers. The meta point seems to be around stating the non-nullable nature of a managed pointer and that invalid pointers can cause problems. I don't think this matters in the spec as it sounds like it is attempting to say that "pointers to non-managed memory are bad", which for the spec is fair and results in undefined behavior, but implementations are free to be resilient to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be explicit in the previous sentence and simply state managed pointers may be null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The particular detail I think its trying to specify, (and it's doing it poorly) is that a managed pointer cannot be an arbitrary pointer, and MUST point to well defined memory location. It doesn't need to be in the managed heap, but it can't be a random pointer into the GC heap. I'll try to come up with some better wording
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like a managed pointer can contain any value that is not in the managed heap. In practice it needs to be zero or to allocated unmanaged space, etc., to avoid the possibility of it being in the managed heap (now by being captured by a future addition to the managed heap), though I suspect the details of how to guarantee a valid "unmanaged value" should be beyond the scope of this document.
Though now that I think about it, "not in the managed heap" seems too permissive. For example, pointers to the stack that are -not- to locals (e.g., to the return address) might be problematic for future implementations (e.g., stack segments), or pointers to internal unmanaged runtime data structures might have some special meaning in a hypothetical future implementation. So perhaps a better form of "not in the managed runtime" would capture the idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, pointers to the native stack are permitted, and we certainly have customers which rely on that behavior, but the notion of requiring the pointer to point at memory explicitly allocated from the native heap, or to a currently in use native stack activation frame might be a better way to describe these pointers.