{"record":{"id":"ed91762a44b99976","repo":"oracle/graal","slug":"invalid-replay-boolean-flag","errorCode":null,"errorMessage":"Invalid replay boolean flag ","messagePattern":"Invalid replay boolean flag ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/BinaryReplayCodec.java","lineNumber":1076,"sourceCode":"        int version = in.readPackedUnsignedInt();\n        if (version != VERSION) {\n            throw new IOException(\"Unsupported replay file version \" + version);\n        }\n    }\n\n    private static void writeBooleanFlag(ObjectCopierOutputStream out, boolean value) throws IOException {\n        out.write(value ? 1 : 0);\n    }\n\n    private static boolean readBooleanFlag(ObjectCopierInputStream in) throws IOException {\n        int value = in.read();\n        if (value < 0) {\n            throw new EOFException();\n        }\n        return switch (value) {\n            case 0 -> false;\n            case 1 -> true;\n            default -> throw new IOException(\"Invalid replay boolean flag \" + value);\n        };\n    }\n\n    private int registrationIndex(CompilerInterfaceDeclarations.Registration registration) {\n        Integer index = registrationIndices.get(registration.clazz());\n        if (index == null) {\n            throw new IllegalArgumentException(\"Unknown registration \" + registration.clazz().getName());\n        }\n        return index;\n    }\n\n    private static Object readSpecialSingleton(int kind) throws IOException {\n        return switch (kind) {\n            case SINGLETON_NULL_POINTER -> JavaConstant.NULL_POINTER;\n            case SINGLETON_COMPRESSED_NULL -> HotSpotCompressedNullConstant.COMPRESSED_NULL;\n            case SINGLETON_NO_SPECULATION -> SpeculationLog.NO_SPECULATION;\n            case SINGLETON_ILLEGAL_VALUE_KIND -> ValueKind.Illegal;\n            default -> throw new IOException(\"Unknown replay singleton kind \" + kind);","sourceCodeStart":1058,"sourceCodeEnd":1094,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/BinaryReplayCodec.java#L1058-L1094","documentation":"readBooleanFlag reads a single byte that must be exactly 0 or 1; anything else throws IOException 'Invalid replay boolean flag <value>'. Since writeBooleanFlag only ever writes 0 or 1, a different value can only mean the stream is corrupt or the reader is misaligned — some earlier value was parsed with a different length than it was written.","triggerScenarios":"Stream corruption; an earlier readValue misconsumed bytes (version skew in encoding of a preceding field); reading a boolean at a position that is actually another value's payload.","commonSituations":"Cross-version replay where a preceding field's packed encoding changed; replay files damaged in transfer or truncated by a killed recording process.","solutions":["Regenerate the replay file with the same build used for replay (removes encoding skew)","Verify the file version header matches before decoding","If corruption is suspected, checksum or re-transfer the file and retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    result = codec.readReplay(in);\n} catch (IOException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Invalid replay boolean flag\")) {\n        // stream corrupt or misaligned: discard file, re-record\n    } else throw e;\n}","preventionTips":["Regenerate replay files whenever either end of the codec changes","Validate the version header before decoding so misalignment is caught at its earliest point"],"tags":["graalvm","replay-compilation","corruption","deserialization","validation"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}