nodejs / nan

Native Abstractions for Node.js
MIT License
3.27k stars 501 forks source link

Nan is enforcing wrong ~1GB kMaxLength for Nan::NewBuffer, should be 4GB #964

Open Rush opened 8 months ago

Rush commented 8 months ago

This resulted in a real-world application issue:

[1] Assertion failed: (size <= imp::kMaxLength && "too large buffer"), function NewBuffer, file nan.h, line 939.

Buffers of 1GB are definitely realistic when dealing with >4k visual data.

The check is implemented here https://github.com/nodejs/nan/blob/e14bdcd1f72d62bca1d541b66da43130384ec213/nan.h#L896

The constant is defined here: https://github.com/nodejs/nan/blob/e14bdcd1f72d62bca1d541b66da43130384ec213/nan.h#L417

I believe it should be 4GB as reported by buffer.constants.MAX_LENGTH (https://nodejs.org/api/buffer.html#bufferkmaxlength)