{"record":{"id":"e33ee1a52ed0ffc9","repo":"oracle/graal","slug":"file-header-is-missing","errorCode":null,"errorMessage":"File header is missing","messagePattern":"File header is missing","errorType":"exception","errorClass":"VersionMismatchException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/BinaryReader.java","lineNumber":846,"sourceCode":"        hashStack.push(null);\n\n        boolean restart = false;\n        long start = System.nanoTime();\n        try {\n            while (true) { // TERMINATION ARGUMENT: finite length of data source will result in\n                           // EOFException eventually.\n                // allows to concatenate BGV files; at the top-level, either BIGV signature,\n                // or 0x00-0x02 should be present.\n                // Check for a version specification\n                if (dataSource.readHeader() && restart) {\n                    // if not at the start of the stream, reinitialize the constant pool.\n                    closeDanglingGroups();\n                    builder.resetStreamData();\n                    constantPool = builder.getConstantPool();\n                }\n                restart = true;\n                if (dataSource.getMajorVersion() < 1) {\n                    throw new VersionMismatchException(\"File header is missing\");\n                }\n                parseRoot();\n            }\n        } catch (EOFException e) {\n            // ignore\n        } finally {\n            // also terminates the builder\n            closeDanglingGroups();\n            if (TRACE_PARSE_TIME) {\n                long end = System.nanoTime();\n                System.err.println(((System.nanoTime() - timeStart) / 1_000_000) + \" Parsed file in \" + ((end - start) / 1_000_000) + \" ms\");\n            }\n\n        }\n        return builder.rootDocument();\n    }\n\n    protected void beginGroup() throws IOException {","sourceCodeStart":828,"sourceCodeEnd":864,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/BinaryReader.java#L828-L864","documentation":"On start, BinaryReader.readHeader looks for the 'BIGV' magic followed by a version pair; if no magic is found the major version stays 0 (or the header parse yields < 1), and parsing aborts with VersionMismatchException('File header is missing'). This means the input is not a graph dump at all, or it uses a pre-versioning (ancient) layout that the current reader refuses.","triggerScenarios":"Passing a plain BGV body without the BIGV header; opening an unrelated file (text, class file, zip) with the graph reader; reading from a stream position before the header was written.","commonSituations":"Wrong file passed to IGV or a programmatic reader; header stripped by preprocessing; concatenation logic that dropped the first chunk's header.","solutions":["Verify the input starts with bytes 'B','I','G','V' before handing it to the reader.","Re-export the graph dump with a current GraalVM producer so the header is present.","If concatenating dumps, keep each chunk's BIGV header (the reader supports restarts on it)."],"exampleFix":"// validation before parsing\nbyte[] head = new byte[4];\ntry (FileInputStream in = new FileInputStream(f)) {\n    if (in.read(head) != 4 || !(head[0]=='B' && head[1]=='I' && head[2]=='G' && head[3]=='V')) {\n        throw new IllegalArgumentException(f + \" is not a BIGV graph dump\");\n    }\n}","handlingStrategy":"validation","validationCode":"byte[] m = new byte[4];\ntry (var in = new java.io.FileInputStream(file)) {\n    if (in.read(m) != 4 || !java.util.Arrays.equals(m, new byte[]{'B','I','G','V'})) {\n        throw new IllegalArgumentException(\"Not a BIGV graph dump: \" + file);\n    }\n}","typeGuard":null,"tryCatchPattern":"try { reader.parse(); } catch (VersionMismatchException e) { if (e.getMessage().contains(\"File header is missing\")) { rejectNonDumpInput(); } }","preventionTips":["Validate the BIGV magic bytes before invoking the reader.","Keep each concatenated chunk's header intact.","Give files explicit .bgv extensions and route them explicitly to the graph reader."],"tags":["graphio","parsing","file-header","validation","corrupt-input"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}