JIT: potential GC hole with collectible code in delegate #105082
Labels
area-CodeGen-coreclr
CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
in-pr
There is an active PR which will close this issue when it is merged
Priority:2
Work that is important, but not critical for the release
Milestone
Originally discovered in #104731 (comment)
When a delegate references collectible code (dynamic method or collectible assembly), and being the only thing keeping the code alive, the code may be collected before invoked.
Consider the following method:
Current codegen on arm64:
The
ldr x2, [x2, #0x18]
instruction loads the function pointer from the delegate object. Now no register holds the delegate object, and GC is not aware of the function pointer inx2
. If GC happens before the nextblr x2
instruction, it may collect the delegate object and associated code.The loop in front of the invocation makes the method fully interruptible, and thus GC can happen at any instruction except prolog/epilog.
All RISC architectures should be suffered from this issue. In xarch, loading the function pointer can be contained in the call instruction like
call [rax+0x18]
, so GC won't lose the track.The text was updated successfully, but these errors were encountered: