Skip to content

Fix GC write barrier when writing async method return into continuation object#126721

Open
BrzVlad wants to merge 1 commit intodotnet:mainfrom
BrzVlad:fix-clrinterp-async-gc
Open

Fix GC write barrier when writing async method return into continuation object#126721
BrzVlad wants to merge 1 commit intodotnet:mainfrom
BrzVlad:fix-clrinterp-async-gc

Conversation

@BrzVlad
Copy link
Copy Markdown
Member

@BrzVlad BrzVlad commented Apr 9, 2026

Previous code was only checking if the type contains GC refs, which means it would fail to add a write barrier if the method returns an object without refs.

Fixes System.Text.Json.Tests random GC crashes

Previous code was only checking if the type contains GC refs, which means it would fail to add a write barrier if the method returns an object without refs.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes missing GC write barriers when an interpreted async method returns a reference type whose instance contains no GC pointers (e.g., System.Object, string), but the return value itself is still an object reference that must be stored with a write barrier.

Changes:

  • Treat non-value-type async returns as object references and store them via SetObjectReference (write barrier).
  • Keep memmoveGCRefs for value-type returns that contain embedded GC references; otherwise use memcpyNoGCRefs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants