Repository navigation
fix: work around koffi leak - #114
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 410d6c4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
genaris
reviewed
Oct 27, 2026
genaris
left a comment
Contributor
There was a problem hiding this comment.
The approach looks correct: decodeCounted decodes a copy, so the original struct keeps the pointer for askar_buffer_free. Can you add a comment that each counted struct must have the same layout as its source struct?
The tests always use a non-null pointer. What does koffi return for a counted pointer that is null, with len 0? An early if (len === 0) return new Uint8Array(0) prevents this case and does not copy the struct.
genaris
approved these changes
Oct 28, 2026
TimoGlastra
force-pushed
the
TimoGlastra/koffi-decode-leaks-audit
branch
from
October 28, 2026 10:55
8db0d82 to
417924d
Compare
TimoGlastra
enabled stacked auto-merge (squash)
October 28, 2026 10:55
TimoGlastra
disabled stacked auto-merge
October 28, 2026 11:24
Build the packages with tsdown, like identity-common, into a single build/index.mjs with index.d.mts types per package. The exports maps only have types and default conditions, plus askar-shared/installBinary for the install scripts. The Node.js package finds its native directory through its own package.json instead of __dirname. Signed-off-by: TimoGlastra <timo@animo.id>
Signed-off-by: TimoGlastra <timo@animo.id>
Signed-off-by: TimoGlastra <timo@animo.id>
Signed-off-by: TimoGlastra <timo@animo.id>
Signed-off-by: TimoGlastra <timo@animo.id>
TimoGlastra
force-pushed
the
TimoGlastra/koffi-decode-leaks-audit
branch
from
October 28, 2026 11:24
417924d to
410d6c4
Compare
This file contains hidden or 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
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.
koffi.decode(ptr, type, len)leaks about 20 bytes on every call (Koromix/koffi#280). Each Askar call that returns bytes or a handle list went through it.Bytes and handle lists are now decoded through a struct whose pointer member is counted by its
lenmember. koffi decodes that without creating an array type, so nothing leaks.