{"record":{"id":"61696d4b6b7ab3b9","repo":"oracle/graal","slug":"too-many-nodes-in-list","errorCode":null,"errorMessage":"Too many nodes in list: ","messagePattern":"Too many nodes in list: ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/GraphProtocol.java","lineNumber":580,"sourceCode":"        int size = findSize(edges);\n        for (int i = 0; i < size; i++) {\n            Collection<? extends Node> list = findNodes(graph, node, edges, i);\n            if (isDirect(edges, i)) {\n                if (list != null && list.size() != 1) {\n                    throw new IOException(\"Edge \" + i + \" in \" + edges + \" is direct, but list isn't singleton: \" + list);\n                }\n                Node n = null;\n                if (list != null && !list.isEmpty()) {\n                    n = list.iterator().next();\n                }\n                writeNodeRef(n);\n            } else {\n                if (list == null) {\n                    writeShort((char) 0);\n                } else {\n                    int listSize = list.size();\n                    if (listSize != ((char) listSize)) {\n                        throw new IOException(\"Too many nodes in list: \" + list.size());\n                    }\n                    writeShort((char) listSize);\n                    for (Node edge : list) {\n                        writeNodeRef(edge);\n                    }\n                }\n            }\n        }\n    }\n\n    private NodeClass classForNode(Node node) throws IOException {\n        NodeClass clazz = findClassForNode(node);\n        if (clazz == null) {\n            throw new IOException(\"No class for \" + node);\n        }\n        return clazz;\n    }\n","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/GraphProtocol.java#L562-L598","documentation":"The dump protocol writes the length of a plural (indirect) edge list as a single 16-bit short. writeEdges therefore rejects any edge list whose size does not round-trip through a char (i.e. > 65535) with IOException('Too many nodes in list'). This mirrors NodeList.checkMaxSize on the compiler side: the wire format itself cannot express larger lists.","triggerScenarios":"Dumping a graph where one node holds more than 65535 entries in a single input/usage list — giant merges, huge call argument lists, or exploded FrameStates from machine-generated code. The compile itself may have already bailed out (PermanentBailoutException at NodeList construction); this error appears when such a shape only arises at dump time or during debug dumping.","commonSituations":"Debug-dumping compilation of generated code (templating/DSL output) with very large methods. Enabling graph dumps (-Dgraal.Dump) on workloads with pathological graph shapes. Custom phases that accidentally accumulate unbounded entries into one node's list.","solutions":["Restructure the input so no single node list exceeds 65535 entries (split merges/calls, chunk generated code).","Check for a phase bug that grows a list unboundedly before assuming the input is genuinely huge.","Disable or scope down graph dumping (-Dgraal.Dump=) for the affected method if the dump is optional and compilation itself is fine.","Verify whether compilation also hits NodeList's PermanentBailoutException — same root limit, fix the shape once for both."],"exampleFix":"// generated shape triggering it\n// before\nNode giant = graph.add(new MergeNode());\nfor (int i = 0; i < 100_000; i++) giant.addPredecessor(end(i)); // > 65535 in one list\n\n// after\n// chunk predecessors into nested merges of <= 50k each so every list fits a short","handlingStrategy":"try-catch","validationCode":"static final int MAX_WIRE_LIST = 0xFFFF;\nfor (Node n : graph.getNodes()) {\n    for (Node input : n.inputs()) { /* count per-edge list sizes */ }\n}\n// simplest guard: reject/split shapes where any single edge list exceeds 65535 before enabling dumps","typeGuard":null,"tryCatchPattern":"try {\n    output.print(graph, ...);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Too many nodes in list\")) {\n        // graph shape exceeds the 16-bit wire limit: skip dumping this graph, fix the shape at the source\n        log.fine(\"Undumpable graph (edge list > 65535): \" + e.getMessage());\n    } else throw e;\n}","preventionTips":["Cap fan-in in generated code so no edge list can approach 65535.","Scope -Dgraal.Dump to specific methods when dumping huge generated workloads.","Remember the same limit triggers PermanentBailoutException at compile time — fix the shape once."],"tags":["java","graal","graphio","limits","dumping","code-generation","wire-format"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}