Skip to content

Error [ERR_INTERNAL_ASSERTION]: Error: Failed to allocate memory WHEN do deepStrictEqual on DataView #62688

@navegador5

Description

@navegador5

Version

v22.4.1

Platform

Linux dli 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

`
var tmpab = new ArrayBuffer(20);
var tmpu8a = new Uint8Array(tmpab);
crypto.getRandomValues(tmpu8a);
/*
Uint8Array(20) [
25, 185, 142, 167, 175, 35,
89, 199, 144, 143, 110, 66,
181, 12, 173, 137, 45, 216,
196, 197
]
*/
var tmpdv = new DataView(tmpab);

var ab = new ArrayBuffer(2429682064); // make a big arraybuffer
var u8a0 = new Uint8Array(ab,76677523,20);
u8a0.set(tmpu8a,0);
/*
Uint8Array(20) [
25, 185, 142, 167, 175, 35,
89, 199, 144, 143, 110, 66,
181, 12, 173, 137, 45, 216,
196, 197
]
*/
;
var dv0 = new DataView(ab,76677523,20); // share same memory-range with u8a0

require("assert").deepStrictEqual(tmpdv,dv0); //----->OK worked as expected

var u8a1 = new Uint8Array(ab,76677523,76677543); // make a larger subarray(larger than ) on same ArrayBuffer
u8a1.set(tmpu8a,0);
/* -------------------------------NO problem here

u8a1
Uint8Array(76677543) [
25, 185, 142, 167, 175, 35, 89, 199, 144, 143, 110, 66,
181, 12, 173, 137, 45, 216, 196, 197, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
... 76677443 more items
]
*/

var dv1 = new DataView(ab,76677523,76677543); // share same memory-range with u8a1
/*

dv1.getUint8(0,true)
25 //OK no problem

*/

for(let i=0;i<tmpdv.byteLength;++i) {assert(tmpdv.getUint8(i,true)===dv1.getUint8(i,true))} //OK
assert(tmpdv.byteLength < dv1.byteLength); //OK

require("assert").deepStrictEqual(tmpdv,dv1); 【it should throw a error like Uncaught [AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:】

BUT it throw a internal error of 【Failed to allocate memory】????
Uncaught:
[Error [ERR_INTERNAL_ASSERTION]: Error [ERR_INTERNAL_ASSERTION]: Error: Failed to allocate memory
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
] {
code: 'ERR_INTERNAL_ASSERTION'
}

`

How often does it reproduce? Is there a required condition?

I think the deepStrictEqual implement of ArrayBufferView is wrong,
why it allocate memory to do compare?
I think compare should be done in-place for array-buffer-view

IF you change to Welcome to Node.js v24.14.0
it can success, but will STUCK for a really long time(5-6 seconds, it seemed nodejs also allocate memory when do comparing)

What is the expected behavior? Why is that the expected behavior?

Uncaught [AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: (If possible, do NOT allocate memory when do deepStrictEqual of array-buffer-view ,finish it inplace)

What do you see instead?

Uncaught:
[Error [ERR_INTERNAL_ASSERTION]: Error [ERR_INTERNAL_ASSERTION]: Error: Failed to allocate memory
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
] {
code: 'ERR_INTERNAL_ASSERTION'
}

Additional information

No response

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