{"record":{"id":"98582a24611a224c","repo":"pinpoint-apm/pinpoint","slug":"invalid-varlong-start-offset-offset-readoffset","errorCode":null,"errorMessage":"invalid varLong. start offset:${offset} readOffset:${offset}","messagePattern":"invalid varLong\\. start offset:(.+?) readOffset:(.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"commons-buffer/src/main/java/com/navercorp/pinpoint/common/buffer/FixedBuffer.java","lineNumber":401,"sourceCode":"        }\n        return (int) readVar64SlowPath();\n    }\n\n\n    /** Variant of readRawVarint64 for when uncomfortably close to the limit. */\n    /* Visible for testing */\n    long readVar64SlowPath() {\n        int copyOffset = this.offset;\n        long result = 0;\n        for (int shift = 0; shift < 64; shift += 7) {\n            final byte b = this.buffer[copyOffset++];\n            result |= (long) (b & 0x7F) << shift;\n            if ((b & 0x80) == 0) {\n                this.offset = copyOffset;\n                return result;\n            }\n        }\n        throw new IllegalArgumentException(\"invalid varLong. start offset:\" +  this.offset + \" readOffset:\" + offset);\n    }\n\n    @Override\n    public int readSVInt() {\n        return BytesUtils.zigzagToInt(readVInt());\n    }\n\n    @Override\n    public short readShort() {\n        final short i = ByteArrayUtils.bytesToShort(buffer, offset);\n        this.offset = this.offset + ByteArrayUtils.SHORT_BYTE_LENGTH;\n        return i;\n    }\n\n    public int readUnsignedShort() {\n        return readShort() & 0xFFFF;\n    }\n","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-buffer/src/main/java/com/navercorp/pinpoint/common/buffer/FixedBuffer.java#L383-L419","documentation":"FixedBuffer.readVar64SlowPath decodes LEB128-style variable-length 64-bit integers. If it reads the maximum number of continuation bytes without hitting a terminating byte (high bit clear), the buffer content is not a valid varLong and it throws IllegalArgumentException 'invalid varLong. start offset:... readOffset:...'.","triggerScenarios":"readVInt() or readVLong() invoked on bytes where the varint never terminates within the allowed shifts — either the byte stream is corrupt, the read offset is misaligned, or a fixed-width value is being read as a varint.","commonSituations":"Deserializing a corrupted/truncated HBase cell value; reading a buffer written by a different codec version (schema mismatch); offset arithmetic errors by the caller before calling readVInt/readVLong; treating non-varint-encoded legacy data as varint.","solutions":["Verify the byte range being decoded actually starts at a varint boundary; fix the caller's offset.","Check data was written by a compatible Pinpoint version (codec/schema mismatch).","Validate or re-write the corrupted row/cell in storage.","Catch IllegalArgumentException around readVInt/readVLong when decoding untrusted data and log the raw bytes."],"exampleFix":"// before\nlong v = buffer.readVLong();\n// after\ntry {\n    long v = buffer.readVLong();\n} catch (IllegalArgumentException e) {\n    logger.warn(\"bad varint at offset, buffer={} \", BytesUtils.toString(buffer.getBuffer()), e);\n    throw new CorruptBufferException(e);\n}","handlingStrategy":"validation","validationCode":"public static boolean isLikelyVarInt(byte[] buf, int offset) {\n    for (int i = 0; i < 10 && offset + i < buf.length; i++) {\n        if ((buf[offset + i] & 0x80) == 0) return true; // terminator found\n    }\n    return false;\n}","typeGuard":null,"tryCatchPattern":"try {\n    long value = buffer.readVLong();\n} catch (IllegalArgumentException e) {\n    logger.warn(\"malformed varint: {}\", e.getMessage());\n    throw new CorruptBufferException(\"bad varint in cell \" + rowKey, e);\n}","preventionTips":["Always read varints at offsets produced by the matching writer's encode path.","Version-stamp serialized payloads and check before decoding.","Fuzz-test decoders against truncated inputs."],"tags":["java","serialization","buffer","deserialization"],"backgroundTag":"invalid-argument-format","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}