indutny / indutny/hash.js

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

Open
#36 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
323
Forks
40
PR merge metrics
No merged PRs in 30d

Description

```js
const fs = require('fs');
const hash = require('hash.js')

async function main() {
let data = await fs.promises.readFile('large126MBfile', { encoding: 'utf8' });
console.log('before');
let sha256 = hash.sha256().update(data).digest('hex');
console.log('after');
}
main();
```
output is:
```
# node --max-old-space-size=67108864 test.js
before

<--- Last few GCs --->

[418310:0x5299b80] 1363 ms: Scavenge 867.2 (900.6) -> 867.2 (900.6) MB, 20.2 / 0.0 ms (average mu = 0.984, current mu = 0.984) allocation failure
[418310:0x5299b80] 1620 ms: Scavenge 1249.7 (1283.2) -> 1249.7 (1283.2) MB, 30.1 / 0.0 ms (average mu = 0.984, current mu = 0.984) allocation failure
[418310:0x5299b80] 2004 ms: Scavenge 1823.5 (1857.0) -> 1823.5 (1857.0) MB, 44.4 / 0.0 ms (average mu = 0.984, current mu = 0.984) allocation failure

<--- JS stacktrace --->

==== JS stack trace =========================================

0: ExitFrame [pc: 0x13ad8f9]
Security context: 0x1ff9fbdc0921
1: toArray [0x185c4cec0df1] [/root/node_modules/hash.js/lib/hash/utils.js:~18] [pc=0x1bdd2c9cad7b](this=0x185c4cec0829 ,0x07ae208c0121 ,0x1e42e08004b9 )
2: update [0x150c16f71df9] [/root/node_...

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

Writing Node.js report to file: report.20220409.203712.418310.0.001.json
Node.js report completed
1: 0x9f1420 node::Abort() [node]
2: 0x9f36e2 node::OnFatalError(char const*, char const*) [node]
3: 0xb5865e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
4: 0xb589d9 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
5: 0xd064e5 [node]
6: 0xcdf111 [node]
7: 0xce0df2 v8::internal::Factory::NewUninitializedFixedArray(int) [node]
8: 0xe518cf [node]
9: 0xe51b6d [node]
10: 0x1003b8b v8::internal::Runtime_GrowArrayElements(int, unsigned long*, v8::internal::Isolate*) [node]
11: 0x13ad8f9 [node]
Aborted (core dumped)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the provided Node.js reproduction and inspect lib/hash/utils.js, especially toArray and update, where the stack trace reports failure. Confirm the behavior with the 126 MB input; the issue does not state a target fix or acceptance criterion, so resolution needs maintainer clarification.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cryptography
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.