From d6712d3e31ee254961c11e75bcf127dc7e0fb660 Mon Sep 17 00:00:00 2001 From: "lingjun.cg" Date: Tue, 8 Oct 2024 13:52:54 +0800 Subject: [PATCH] [Runtime] CRaC: fix the bug that cannot restore pipe fd successful. Summary: If the image dir is a relative path, the criuenginue process cannot write to the pipefds file in image dir.So convert it to real path before do checkpointing. Testing: jdk/jdk/crac/AppendAppClassLoaderTest.java,jdk/jdk/crac/RestorePipeFdTest.java Reviewers: yansendao.ysd,lvfei.lv Issue: https://github.com/dragonwell-project/dragonwell11/issues/867 --- src/java.base/unix/native/criuengine/criuengine.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/java.base/unix/native/criuengine/criuengine.c b/src/java.base/unix/native/criuengine/criuengine.c index 524878d1d01..5c3547f5c84 100644 --- a/src/java.base/unix/native/criuengine/criuengine.c +++ b/src/java.base/unix/native/criuengine/criuengine.c @@ -214,7 +214,12 @@ static int checkpoint(pid_t jvm, const char *basedir, const char *self, } *arg++ = NULL; - setenv("CRAC_IMAGE_DIR", imagedir, 1); + char resolved_path[PATH_MAX]; + if (realpath(imagedir, resolved_path) == NULL) { + perror("get real path for image dir error"); + exit(1); + } + setenv("CRAC_IMAGE_DIR", resolved_path, 1); execv(criu, (char **)args); perror("criu dump"); exit(1);