Repository navigation
Conversation
nbd168
commented
Oct 17, 2026
Contributor
- fix extra reference on the prototype in proto()
- release old instance prototype of a resource
ucv_prototype_set() keeps the reference it is given. Since commit c3dc162 ("lib: reject circular prototype chains in proto()"), uc_proto() passes it an owned reference, but it still takes the second reference that used to balance the borrowed one. Each successful proto(value, prototype) call thus leaks one reference on the prototype, which is then never freed. Drop the extra reference, and test that a prototype holds exactly one reference per value that uses it. Fixes: c3dc162 ("lib: reject circular prototype chains in proto()") Signed-off-by: Felix Fietkau <nbd@nbd.name>
jow-
reviewed
Oct 17, 2026
| @@ -0,0 +1,30 @@ | |||
| Setting the prototype of a library handle releases the previous one. | |||
Collaborator
There was a problem hiding this comment.
I'd rather fold this testcase into the existing generic 40_proto one and make it skip itself if require("ffi") fails. You can acquire ffi.C from the scope returned by require().
For an extended resource with an instance prototype slot,
ucv_prototype_set() overwrites the slot without a release of the
prototype it holds. The resource owns that reference, since the free
path puts every value slot, so each proto(resource, prototype) call
leaks the earlier prototype. Reachable from script for ffi library
handles, for example proto(ffi.C, {}).
Store the prototype with ucv_resource_proto_set(), which releases the
earlier value, like the array and object cases do.
Fixes: c404fe2 ("types: add per-instance prototype support for extended resources")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This branch has not been deployed
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.