[0.2] Update to LDK 0.2 (for real this time)#179
Merged
TheBlueMatt merged 15 commits intolightningdevkit:0.2from Dec 11, 2025
Merged
[0.2] Update to LDK 0.2 (for real this time)#179TheBlueMatt merged 15 commits intolightningdevkit:0.2from
TheBlueMatt merged 15 commits intolightningdevkit:0.2from
Conversation
Once we're generating code here we don't know whether an argument passed by reference is actually something the callee holds on to as a reference or if it just needs it temporarily. This means we have to add a `refs_to` pointer to the passed object to the method owner, potentially holding on to objects long after they're needed. In one specific case, `ChannelManager::pay_for_bolt11_invoice` holds on to the passed `Bolt11Invoice`, potentially leaking memory on every paid invoice. Sadly there's not a great fix for this in that we don't want to take the less conservative stance and assume the passed object isn't held on to (though it would very likely work in practice!). Instead, here, we bite the bullet and just clone everything we can as we pass it into Rust, avoiding the reference entirely.
This is compiled fine, but clang does warn that its forbidden in ISO C, and is obviously nonsense so might as well drop.
Sadly this appears to be triggering now, I suspect a toolchain update is leading to some `malloc` wraps not wrapping, as there are no functional issues in the tests (and other languages don't trigger address sanitizer). Thus, we simply remove the hard-assert.
Collaborator
Author
|
Determinism test passed (with this commit!) at https://github.com/TheBlueMatt/ldk-garbagecollected/actions/runs/20143315609 (though with C# continuing to be a problem child and macOS being very insistent on 4-byte UUIDs) |
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.
Reset the branch cause I realized I pushed the wrong commit, so let's do this again.
In addition to the update itself, we also switch to much more clone'ing, hopefully removing memory "leaks" though with some performance tradeoff:
Once we're generating code here we don't know whether an argument
passed by reference is actually something the callee holds on to
as a reference or if it just needs it temporarily. This means we
have to add a refs_to pointer to the passed object to the method
owner, potentially holding on to objects long after they're needed.
In one specific case, ChannelManager::pay_for_bolt11_invoice
holds on to the passed Bolt11Invoice, potentially leaking memory
on every paid invoice.
Sadly there's not a great fix for this in that we don't want to
take the less conservative stance and assume the passed object
isn't held on to (though it would very likely work in practice!).
Instead, here, we bite the bullet and just clone everything we can
as we pass it into Rust, avoiding the reference entirely.