Skip to content

reproducable out-of-memory errors using 'array' #79

@ollixx

Description

@ollixx

hi there,

the following code snippets result in a hard crash and should probably be hardened to throw an error instead:

let jBinary = require("jbinary");
let buf = [0x00, 0x03, 0x04, 0x05, 0x06, 0x07];
let b = new jBinary(buf);
// works:
console.log(b.read(['array', 2]));
// crash:
console.log(b.read(['array', undefined]));
let jBinary = require("jbinary");
let buf = [0x00, 0x03, 0x04, 0x05, 0x06, 0x07];
let b = new jBinary(buf);
// crash:
console.log(b.read('array', <any number here>));

on my system (node-red 2.2.3, node.js v14.18.2, in docker container), I see this error:

<--- Last few GCs --->

[17:0x564b6caeeaa0]  1558415 ms: Mark-sweep 1077.3 (1097.0) -> 837.9 (857.2) MB, 385.8 / 0.0 ms  (+ 1.8 ms in 2 steps since start of marking, biggest step 1.2 ms, walltime since start of marking 910 ms) (average mu = 0.999, current mu = 0.629) allocation [17:0x564b6caeeaa0]  1559490 ms: Mark-sweep 1411.7 (1431.0) -> 603.7 (621.5) MB, 747.3 / 0.0 ms  (average mu = 0.995, current mu = 0.305) allocation failure scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions