Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable caching in ArrayBuffer #611

Closed

Conversation

tniessen
Copy link
Member

@tniessen tniessen commented Nov 28, 2019

Caching the data pointer and the byteLength in the ArrayBuffer class causes it to behave incorrectly when the buffer is detached, as demonstrated by the test case. The current behavior is dangerous since it depends on whether the Napi::Value was cast to an Napi::ArrayBuffer before or after being detached.

@tniessen tniessen force-pushed the disable-caching-in-arraybuffer branch from fbf3354 to 6f1cd3e Compare November 28, 2019 14:02
Caching the data pointer and the byteLength in the ArrayBuffer class
causes it to behave incorrectly when the buffer is detached.
@tniessen tniessen force-pushed the disable-caching-in-arraybuffer branch from 6f1cd3e to 25686d8 Compare November 28, 2019 14:53
Copy link
Member

@NickNaso NickNaso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tniessen good catch. Could I ask you to add a forward declaration for ArrayBuffer in napi.h and place it after Array?
Thanks for this contribution.

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM seems reasonable to me.

Copy link
Member

@NickNaso NickNaso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tniessen Thanks

@tniessen
Copy link
Member Author

@NickNaso Done. May I ask why that is necessary?

@tniessen tniessen added the bug label Dec 1, 2019
gabrielschulhof pushed a commit that referenced this pull request Dec 14, 2019
Caching the data pointer and the byteLength in the ArrayBuffer class
causes it to behave incorrectly when the buffer is detached.

PR-URL: #611
Reviewed-By: Nicola Del Gobbo <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
@gabrielschulhof
Copy link
Contributor

Landed in b72f1d6.

@tniessen tniessen deleted the disable-caching-in-arraybuffer branch January 23, 2020 03:47
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
Caching the data pointer and the byteLength in the ArrayBuffer class
causes it to behave incorrectly when the buffer is detached.

PR-URL: nodejs/node-addon-api#611
Reviewed-By: Nicola Del Gobbo <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
Caching the data pointer and the byteLength in the ArrayBuffer class
causes it to behave incorrectly when the buffer is detached.

PR-URL: nodejs/node-addon-api#611
Reviewed-By: Nicola Del Gobbo <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
Caching the data pointer and the byteLength in the ArrayBuffer class
causes it to behave incorrectly when the buffer is detached.

PR-URL: nodejs/node-addon-api#611
Reviewed-By: Nicola Del Gobbo <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
Caching the data pointer and the byteLength in the ArrayBuffer class
causes it to behave incorrectly when the buffer is detached.

PR-URL: nodejs/node-addon-api#611
Reviewed-By: Nicola Del Gobbo <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants