-
Notifications
You must be signed in to change notification settings - Fork 3
fix(NODE-6326): explicitly chain object lifetimes #42
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
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The tests were previously encountering issues because creating an encryption/decryption context would not necessarily keep the parent `mongocrypt_t` alive, leading to intermittent crashes. It appears that a similar issue has shown itself in the past w.r.t. KMS requests; the solution chosen there was to "chain" the object lifetimes through a JS property link on the wrapper objects for each C++ object. This approach mostly works, but it is a bit brittle, because the JS engine and Node-API do not make strict guarantees about the order in which C++ wrapper objects are destroyed. This commit tries to fully solve this problem by leaving it to the C++ wrapper objects to explicitly define lifetime relationships between them.
68c9011
to
d3d785b
Compare
(resolved merge conflicts from main) |
I ran a patch against the driver using the changes here - everything looks good: https://spruce.mongodb.com/version/66d76a0742b67c0007b544a6/tasks?sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC (accidentally ran windows test too, ignore those) |
baileympearson
approved these changes
Sep 3, 2024
nbbeeken
approved these changes
Sep 5, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Happy to get #41 merged first, then open this against a regular PR against the main branch with a NODE ticket and everything.
Description
What is changing?
The tests were previously encountering issues because creating an encryption/decryption context would not necessarily keep the parent
mongocrypt_t
alive, leading to intermittent crashes.It appears that a similar issue has shown itself in the past w.r.t. KMS requests; the solution chosen there was to "chain" the object lifetimes through a JS property link on the wrapper objects for each C++ object.
This approach mostly works, but it is a bit brittle, because the JS engine and Node-API do not make strict guarantees about the order in which C++ wrapper objects are destroyed.
This commit tries to fully solve this problem by leaving it to the C++ wrapper objects to explicitly define lifetime relationships between them.
Is there new documentation needed for these changes?
No.
What is the motivation for this change?
The addon may crash. It currently only does so in tests, but it's not fundamentally impossible for this issue to show up in real-world usage.
Release Highlight
Fill in title or leave empty for no highlight
Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript