nodejs / nodejs/nan

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

Open
#964 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
3.4k
Forks
531
Avg merge
21m
Merged PRs (30d)
1

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in nan.h around the constant definition at line 417 and the NewBuffer check around lines 896 and 939. Compare the limit with Node.js buffer.constants.MAX_LENGTH; the issue is done when the check permits the reported supported maximum and the relevant project validation passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, node.js
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.