Fix constrefs RCP restore - #24560
Conversation
8ebd72f to
098150f
Compare
62e0f9c to
e1c351f
Compare
ced707d to
afedf9a
Compare
nbhuiyan
left a comment
There was a problem hiding this comment.
This implementation is clearing the stale constRefArray during a restore run. However, I believe the better approach is to do the clearing in VMSnapshotImpl::fixupClass(), as recommended in #24454 (comment). Doing that would remove the need to clear them in the restore run.
|
Please rename this PR to "Fix constrefs RCP restore", RCP != CRIU this is a completely different mechanism |
| * This must happen before JIT_INITIALIZED so that JIT compilation threads | ||
| * do not see stale pointers into the old constRefArrayPool. | ||
| */ | ||
| if (IS_RESTORE_RUN(vm)) { |
There was a problem hiding this comment.
this should be done at the end of a checkpoint run, not during restore
There was a problem hiding this comment.
I see @nbhuiyan mentions VMSnapshotImpl::fixupClass(), this is the correct place.
afedf9a to
a8fc29b
Compare
584f8aa to
07f58fa
Compare
On a snapshot restore run, classes loaded from the snapshot have constRefArrays pointers that point into the old constRefArrayPool from the previous run, which no longer exists. the stale pointers cause a crash when dereferenced during JIT compilation. The fix is to null clazz->constRefArrays in VMSnapshotImpl::fixupClass() at checkpoint time, so the snapshot is written with clean pointers and no stale references. Assisted-by: IBM Bob Signed-off-by: Saad Younus <saad.younus@ibm.com>
07f58fa to
9b84a7d
Compare
|
Updated the fix based on the feedback. Nulling out constRefArrays in Note: testing required disabling ASLR (echo 0 | sudo tee /proc/sys/kernel/randomize_va_space) to reproduce the original crash consistently. Not disabling ASLR will lead to a separate unrelated crash. |
Problem
On a snapshot restore run, classes loaded from the snapshot have ConstRef pointers that point into the old ConstRefPool from the previous run, which no longer exists. They would eventually get dereferenced and cause a crash.
Fix
Walk class memory segments directly (bypassing the frozen class filter) before
JIT_INITIALIZED, nulling the references on all classes including frozen ones.Testing
Reproduced the original crash and confirmed the server starts cleanly on every restore run with the fix applied.
Fixes: #24454