oracle/graal · error · IOException

Unbalanced groups

Error message

Unbalanced groups

What it means

BinaryReader tracks folderLevel as BEGIN_GROUP/CLOSE_GROUP entries pair up; doCloseGroup decrements it and throws IOException('Unbalanced groups') when it was already 0, i.e. the stream contains a CLOSE_GROUP root entry with no open group. This indicates malformed group nesting: corrupted bytes, a hand-built stream, or a writer bug that emitted an extra group terminator.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/BinaryReader.java:876

            }

        }
        return builder.rootDocument();
    }

    protected void beginGroup() throws IOException {
        parseGroup();
        folderLevel++;
        hashStack.push(null);
        // note: startGroupContent MAY throw SkipRootException; but unlike graph
        // group contains root terminator byte, which will be read by parseRoot()
        // immediately after.
        builder.startGroupContent();
    }

    private void doCloseGroup() throws IOException {
        if (folderLevel-- == 0) {
            throw new IOException("Unbalanced groups");
        }
        builder.endGroup();
        hashStack.pop();
        reporter.popContext();
    }

    protected void parseRoot() throws IOException {
        try {
            builder.startRoot();
            int type = dataSource.readByte();
            // startRoot may also throw SkipRootException
            switch (type) {
                case BEGIN_GRAPH: {
                    parseGraph();
                    break;
                }
                case BEGIN_GROUP: {
                    beginGroup();

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Regenerate the dump with a stock producer and retry.
  2. Verify the file's structural integrity (root-entry sequence should begin with BEGIN_GROUP or GRAPH entries only).
  3. If writing a custom producer, ensure every CLOSE_GROUP is paired with exactly one preceding BEGIN_GROUP.
Defensive patterns

Strategy: try-catch

Try / catch

try { reader.parse(); } catch (IOException e) { if ("Unbalanced groups".equals(e.getMessage())) { /* malformed nesting: regenerate dump */ } }

Prevention

When it happens

Trigger: A CLOSE_GROUP root-level entry appearing before any BEGIN_GROUP; truncation/corruption shifting root-entry tags; custom producers that write group terminators without matching group starts.

Common situations: Viewing damaged or hand-assembled dump files; interrupted dumps that were partially repaired; producer forks with incorrect group nesting logic.

Related errors


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