Skip to content

Fix constrefs RCP restore - #24560

Open
saad-ibm wants to merge 1 commit into
eclipse-openj9:masterfrom
saad-ibm:fix-constrefs-criu-restore
Open

Fix constrefs RCP restore#24560
saad-ibm wants to merge 1 commit into
eclipse-openj9:masterfrom
saad-ibm:fix-constrefs-criu-restore

Conversation

@saad-ibm

@saad-ibm saad-ibm commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

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

@saad-ibm
saad-ibm force-pushed the fix-constrefs-criu-restore branch from 8ebd72f to 098150f Compare August 14, 2026 19:47
@saad-ibm
saad-ibm requested a review from dsouzai as a code owner August 14, 2026 19:47
@saad-ibm
saad-ibm force-pushed the fix-constrefs-criu-restore branch 2 times, most recently from 62e0f9c to e1c351f Compare August 14, 2026 19:53
@saad-ibm
saad-ibm marked this pull request as draft August 14, 2026 19:56
@saad-ibm
saad-ibm force-pushed the fix-constrefs-criu-restore branch 2 times, most recently from ced707d to afedf9a Compare August 14, 2026 20:08
@saad-ibm
saad-ibm marked this pull request as ready for review August 18, 2026 14:03
@nbhuiyan nbhuiyan self-assigned this Aug 21, 2026

@nbhuiyan nbhuiyan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@tajila

tajila commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Please rename this PR to "Fix constrefs RCP restore", RCP != CRIU this is a completely different mechanism

Comment thread runtime/vm/jvminit.c Outdated
* 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)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this should be done at the end of a checkpoint run, not during restore

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see @nbhuiyan mentions VMSnapshotImpl::fixupClass(), this is the correct place.

@saad-ibm saad-ibm changed the title Fix constrefs criu restore Fix constrefs RCP restore Aug 25, 2026
@saad-ibm
saad-ibm force-pushed the fix-constrefs-criu-restore branch from afedf9a to a8fc29b Compare August 25, 2026 14:30
@saad-ibm
saad-ibm marked this pull request as draft August 26, 2026 17:55
@saad-ibm
saad-ibm force-pushed the fix-constrefs-criu-restore branch 10 times, most recently from 584f8aa to 07f58fa Compare September 1, 2026 18:26
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>
@saad-ibm
saad-ibm force-pushed the fix-constrefs-criu-restore branch from 07f58fa to 9b84a7d Compare September 2, 2026 18:29
@saad-ibm

saad-ibm commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Updated the fix based on the feedback. Nulling out constRefArrays in VMSnapshotImpl::fixupClass() effectively moves the same fix from happening during restore to the end of a checkpoint. Also, VMSnapshotImpl::fixupClass() is called from VMSnapshotImpl::fixupClasses() which walks all classes before J9ClassIsFrozen is set. This means all classes have their constRefArrays nulled before the snapshot is written, meaning no stale pointers exist on restore.

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.

@saad-ibm
saad-ibm marked this pull request as ready for review September 2, 2026 19:23
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.

Open Liberty Server crashed in the startup of RCP production run

3 participants