Skip to content

RangeError when reading record data length #89

@staltz

Description

@staltz

I got this crash report from Manyverse. I still don't know what the reproduction steps are, but reporting all the details I can, maybe it helps figure this out.

Versions

  • App: Manyverse 0.2210.3
  • OS: iOS 21.6.0 (is this an actual iOS version? that's what the crash claims)
  • Node runtime: 12.19.0
  • ssb-db2: 4.2.1
  • jitdb: 7.0.5
  • async-append-only-log: 4.3.7
  • random-access-file: 2.2.1

Resources

  • RAM: 3.6 GiB of which only 146.6 MiB free
  • Processor count: 6
  • Architecture: arm64

Code block

const HEADER_SIZE = 2 // uint16
function size(dataBuf) {
  return HEADER_SIZE + dataBuf.length
}
function readDataLength(blockBuf, offsetInBlock) {
  return blockBuf.readUInt16LE(offsetInBlock) //             <-----------------------
}
function readSize(blockBuf, offsetInBlock) {
  const dataLength = readDataLength(blockBuf, offsetInBlock)
  return HEADER_SIZE + dataLength
}

Stack trace

RangeError: The value of "offset" is out of range. It must be >= 0 and <= 65534. Received 95084
  File "internal/buffer.js", line 81, col 9, in boundsError
  File "internal/buffer.js", line 238, col 5, in Buffer.readUInt16LE
  File "nodejs-project/index.js", line 109582, col 19, in Object.readDataLength
  File "nodejs-project/index.js", line 111380, col 31, in Object.getDataNextOffset
  File "nodejs-project/index.js", line 47642, col 44, in Stream._handleBlock
  File "nodejs-project/index.js", line 47701, col 27, in Stream._resumeCallback
  File "nodejs-project/index.js", line 111353, col 9, in Request.onRAFReadDone [as _callback]
  File "nodejs-project/index.js", line 138474, col 8, in Request.callback
  File "nodejs-project/index.js", line 24593, col 31, in onread
  File "fs.js", line 520, col 5, in FSReqCallback.wrapper [as oncomplete]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions