Skip to content

Null fields should have the correct type#1377

Merged
leculver merged 2 commits intomicrosoft:mainfrom
leculver:fix/1342-null-object-type
Feb 20, 2026
Merged

Null fields should have the correct type#1377
leculver merged 2 commits intomicrosoft:mainfrom
leculver:fix/1342-null-object-type

Conversation

@leculver
Copy link
Copy Markdown
Contributor

@leculver leculver commented Feb 19, 2026

Fix issue raised in #1370. Null fields shouldn't use GetObject(null) because that does not properly set the type.

leculver and others added 2 commits February 19, 2026 05:45
When ReadObjectField reads a null pointer (obj == 0), use the field's
declared type instead of looking up the heap, which would return
ErrorType. For non-null objects, continue reading the actual runtime
type from the heap to preserve polymorphism.

Fixes microsoft#1342.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Verifies that ReadObjectField returns the field's declared type
(SamplePointerType) when the field value is null, rather than
ErrorType.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@shvez
Copy link
Copy Markdown
Contributor

shvez commented Feb 19, 2026

while we are here, I noticed that null value is reported as 'invalid'. IsValid returns false.
Is it correct?

@leculver
Copy link
Copy Markdown
Contributor Author

leculver commented Feb 19, 2026

That might be a bit confusing but it's meant to be that way. IsValid means "this ClrObject instance points to a valid object that is allocated in memory in the target process". Even though null is something that is allowed to be there, the address 0 doesn't point to a valid object.

@leculver leculver merged commit c56d369 into microsoft:main Feb 20, 2026
8 checks passed
@leculver leculver deleted the fix/1342-null-object-type branch February 20, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants