oracle/graal · error · InternalError

Profile file for path %s exists already

Error message

Profile file for path %s exists already

What it means

InternalError thrown by ProfileReplaySupport when saving method profiles (-Dgraal.SaveProfilesPath=...) and the target .glog file already exists while -Dgraal.OverrideProfiles is false. The guard exists because blindly overwriting would destroy previously collected replay profiles for that method.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/ProfileReplaySupport.java:271

                }
            }
            if (SaveProfiles.getValue(debug.getOptions())) {
                try (DebugContext.Scope scope = debug.scope("ProfileReplay")) {
                    EconomicMap<String, Object> map = EconomicMap.create();
                    map.put("identifier", compilationId.toString());
                    map.put("method", method.format("%H.%n(%P)%R"));
                    map.put("entryBCI", entryBCI);
                    map.put("codeSignature", codeSignature);
                    map.put("graphSignature", graphSignature);
                    map.put("result", result != null);
                    profileProvider.recordProfiles(map, profileSaveFilter, lambdaNameFormatter);
                    String path = null;
                    if (Options.SaveProfilesPath.getValue(debug.getOptions()) != null) {
                        String fileName = PathUtilities.sanitizeFileName(method.format("%h.%n(%p)%r") + ".glog");
                        String dirName = Options.SaveProfilesPath.getValue(debug.getOptions());
                        path = Paths.get(dirName).resolve(fileName).toString();
                        if (new File(path).exists() && !Options.OverrideProfiles.getValue(debug.getOptions())) {
                            throw new InternalError("Profile file for path " + path + " exists already");
                        }
                    } else {
                        path = debug.getDumpPath(".glog", false, false);
                    }
                    try (JsonPrettyWriter writer = new JsonPrettyWriter(new PrintWriter(PathUtilities.openOutputStream(path)))) {
                        writer.print(map);
                    }
                } catch (Throwable t) {
                    throw debug.handle(t);
                }
            }
        }
    }

    private static String getCanonicalGraphString(StructuredGraph graph) {
        SchedulePhase.runWithoutContextOptimizations(graph, SchedulePhase.SchedulingStrategy.EARLIEST);
        StructuredGraph.ScheduleResult scheduleResult = graph.getLastSchedule();
        NodeMap<Integer> canonicalId = graph.createNodeMap();

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Add -Dgraal.OverrideProfiles=true to overwrite existing profile files.
  2. Point -Dgraal.SaveProfilesPath at a fresh/unique directory for each run.
  3. Delete or move the existing .glog files before recollecting.

Example fix

# before
-Dgraal.SaveProfilesPath=/tmp/profiles
# second run -> InternalError

# after
-Dgraal.SaveProfilesPath=/tmp/profiles -Dgraal.OverrideProfiles=true
Defensive patterns

Strategy: validation

Validate before calling

// Before each profiling run, ensure the target dir is fresh or override is enabled
Path dir = Paths.get(System.getProperty("graal.SaveProfilesPath"));
boolean override = Boolean.parseBoolean(System.getProperty("graal.OverrideProfiles", "false"));
if (!override && Files.isDirectory(dir)) {
    try (var s = Files.list(dir)) {
        if (s.anyMatch(p -> p.toString().endsWith(".glog"))) {
            throw new IllegalStateException("Stale .glog files present; move them or set -Dgraal.OverrideProfiles=true");
        }
    }
}

Try / catch

try {
    // run JVM with -Dgraal.SaveProfilesPath=...
} catch (InternalError e) {
    if (e.getMessage().contains("exists already")) { /* archive dir contents, rerun */ }
    throw e;
}

Prevention

When it happens

Trigger: Enabling Options.SaveProfilesPath and compiling the same method twice into the same directory without Options.OverrideProfiles=true; rerunning a benchmark or test suite that recompiles the same methods.

Common situations: Collecting replay profiles for a benchmark: first run writes Foo.glog, a second run (or a second JVM in the same output dir) collides. Also stale files left from an earlier collection.

Related errors


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/e1465bdffbc6fe06. Report an issue: GitHub.