Debug On Restore: invalidate all method bodies if needed #20741
Closed
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.
Under
-XX:+DebugOnRestore
, if-Xnoaot -Xjit
is specified post restore, the compiler invalidates all compiled bodies. It does so by callingTR::Recompilation::invalidateMethodBody
. This, in tandem with other factors described below, can lead to a hang:-Xnoaot -Xnojit
is specified, resulting in the startPC of the recompiled foo getting patched to trigger a sync recompilation-Xnoaot -Xnojit
, the sync recompilation fails; this results in the startPC of the recompiled foo (from step 2) getting patched to revert to the interpreter.J9_STARTPC_NOT_TRANSLATED
)-Xnoaot -Xnojit
), which results in the extra getting set to -3 (J9_JIT_NEVER_TRANSLATE
)j9jit_testarossa_err
, because compilation happens asynchronously and becauselinkageInfo->isBeingCompiled()
returns true; this flag never gets reset even after the recompilation succeeds in step 2.The fix for this hang is to call
TR::Recompilation::methodCannotBeRecompiled
rather thanTR::Recompilation::invalidateMethodBody
, and to call it on all compiled bodies, including the old stubs of bodies that were recompiled. This is OK to do because this happens anyway for the "invalidated" recompiled body in step 4, and this would have happened in step 10 if the early return never occurred.It remains to be determined whether resetting the flag in step 10 to prevent the early return is safe.
Fixes #20663
I'll open another issue to track fixing this in a more general case (as this issue is technically possible even outside of
-XX:+DebugOnRestore
and CRIU.