Skip to content

Array functions: missing max dimension guard causes OOM crash #1646

@marcin-kordas-hoc

Description

@marcin-kordas-hoc

Severity: Critical

Array-producing functions have no upper bound on output dimensions. Formulas like =SEQUENCE(999999999) or =SEQUENCE("1e308") pass all validation checks and attempt to allocate massive arrays, causing an out-of-memory crash with no error returned.

Reproduction

const hf = HyperFormula.buildFromArray([['=SEQUENCE(999999999)']], { licenseKey: 'gpl-v3' })
// OOM crash — no error returned, process killed

Also crashes: =SEQUENCE("1e308") (string coerces to finite 1e308, passes isFinite check).

Expected behavior

Should return an error. Excel returns #VALUE! when dimensions exceed sheet limits (1048576 rows, 16384 columns).

Affected scope

  • SequencePlugin — no max dimension check in isValidDimension or sequenceArraySize
  • Potentially any function with sizeOfResultArrayMethod that accepts user-controlled dimensions

Suggested fix

Add max dimension validation, e.g. derived from Config.maxRows / Config.maxColumns:

private static isValidDimension(n: number): boolean {
  return Number.isFinite(n) && n >= SequencePlugin.MIN_DIMENSION && n <= MAX_SAFE_DIMENSION
}

Found during SEQUENCE implementation (PR #1645).

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIPublic methods and propertiesBugSomething isn't workingImpact: Medium

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions