Skip to content

Conversation

@TheBlueMatt
Copy link
Collaborator

No description provided.

Rust's memory allocator doesn't allocate for 0-byte allocations.
However, standard `libc` does. As a result, Rust also doesn't free
0-byte allocations whereas `libc`-based C code will rely on such
allocation being free'd.

This breaks our bindings somewhat as we may allocate for 0-byte
strings or arrays, but once we pass them to Rust they will not be
freed.

Here we skip such allocations when we pass strings to Rust,
avoiding leaks when empty strings are passed.
Rust's memory allocator doesn't allocate for 0-byte allocations.
However, standard `libc` does. As a result, Rust also doesn't free
0-byte allocations whereas `libc`-based C code will rely on such
allocation being free'd.

This breaks our bindings somewhat as we may allocate for 0-byte
strings or arrays, but once we pass them to Rust they will not be
freed.

Here we skip such allocations when we pass byte arrays (in the form
of u8-vecs, as well as a few other types), avoiding leaks when
empty arrays are passed.
Now that the bindings use a real `Address` type instead of a string
we need to have a class for it in our languages.
Most of our conversion was originally written for Java, where there
are no unsigned integers, but now that we're also targeting
TypeScript with strongly-typed arrays we should actually track
signed and unsigned integers as separate types.

Note that this will let us use `*IntArray` types more in TypeScript
giving our users additional type information.
@TheBlueMatt TheBlueMatt linked an issue Apr 8, 2025 that may be closed by this pull request
This should resolve build errors when using .NET 9.0 due to
conflicts between our `UInt128` type and `System.UInt128`.
This should allow tests to be built targeting .NET 9.0
Newer .NET runtimes allow it to throw `ThreadInterruptedException`
which can cause our tests to fail.
Modern NDK no longer ships a `$TARGET-strip` binary, but does ship
`llvm-strip`, which seems to imply they'd prefer that be used.

Thus, we hard-code `llvm-strip` in `android-build.sh`
This allows our own code to do things like
`(a instanceof Option_ThingZ_Some)`, though it doesn't impact the
public API.
`NetworkGraph` now pre-allocates the appropriate size, which causes
our tests to use a bit more than 1GB in memory, so we simply turn
off the limit.
While some of our determinism checks fail for trivial cases
(specifically for macOS and Windows builds), we still want CI jobs
to fail to ensure they get manual verification.
@TheBlueMatt
Copy link
Collaborator Author

CI determinism "passed" at https://github.com/TheBlueMatt/ldk-garbagecollected/actions/workflows/build.yml

@TheBlueMatt TheBlueMatt merged commit 92188e7 into lightningdevkit:main Apr 9, 2025
3 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Android in C# nupkg

1 participant