{"record":{"id":"f2675dc4fe9b743c","repo":"oracle/graal","slug":"cannot-bind-label-to-negative-position-d","errorCode":null,"errorMessage":"Cannot bind label to negative position %d","messagePattern":"Cannot bind label to negative position (.+?)","errorType":"exception","errorClass":"GraalError","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/Label.java","lineNumber":78,"sourceCode":"    public Label() {\n        blockId = -1;\n    }\n\n    public Label(int id) {\n        blockId = id;\n    }\n\n    public int getBlockId() {\n        return blockId;\n    }\n\n    /**\n     * Binds the label to {@code pos} and patches all instructions added by\n     * {@link #addPatchAt(int, Assembler)}.\n     */\n    protected void bind(int pos, Assembler<?> asm) {\n        if (pos < 0) {\n            throw new GraalError(\"Cannot bind label to negative position %d\", pos);\n        }\n        this.position = pos;\n        if (patchPositions != null) {\n            for (int i = 0; i < patchPositions.size(); ++i) {\n                asm.patchJumpTarget(patchPositions.get(i), position);\n            }\n            patchPositions = null;\n        }\n    }\n\n    public boolean isBound() {\n        return position >= 0;\n    }\n\n    public void addPatchAt(int branchLocation, Assembler<?> asm) {\n        assert !isBound() : \"Label is already bound \" + this + \" \" + branchLocation + \" at position \" + position;\n        if (patchPositions == null) {\n            patchPositions = new ArrayList<>(2);","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/Label.java#L60-L96","documentation":"Thrown by readPrimitiveArrayUnaligned when the array constant is not an EspressoExternalObjectConstant. The unaligned read decodes bytes directly from the guest array via interop buffer access (readBufferByte/Short/Int/Long/...), which requires an espresso object constant holding the polyglot Value.","triggerScenarios":"Passing a host constant, primitive constant, or foreign-backend constant as the array argument.","commonSituations":"Constants crossing backend boundaries (host JVMCI -> espresso access); mocks; stale constants from a previous guest context.","solutions":["Only pass espresso object constants obtained from the same vm access instance","Guard with instanceof and route non-espresso constants to the host unaligned read implementation"],"exampleFix":"// before\nJavaConstant v = vmAccess.readPrimitiveArrayUnaligned(anyConst, kind, offset);\n\n// after\nJavaConstant v = anyConst instanceof EspressoExternalObjectConstant\n        ? vmAccess.readPrimitiveArrayUnaligned(anyConst, kind, offset)\n        : hostBackend.readUnaligned(anyConst, kind, offset);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean isEspressoObjectConstant(JavaConstant c) {\n    return c instanceof EspressoExternalObjectConstant;\n}","tryCatchPattern":null,"preventionTips":["Keep one backend's constants with that backend's access object","Re-snapshot constants after guest context restarts instead of reusing old ones"],"tags":["espresso","jvmci","unaligned-read","constant","type-guard"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}