Afshin Arani [Sun, 10 Mar 2024 10:40:17 +0000 (12:40 +0200)]
CSharp: fix LDKStr array decoding
Strings are encoded as array of string references, those references
are actually pointers to the string location and have 64bit in size,
but decoding logic was decoding those pointers as 32bit which caused
the following exception, this commit fixes that.
Exception:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at InternalUtils.getArrayLength(Int64)
at InternalUtils.decodeUint8Array(Int64)
at InternalUtils.decodeString(Int64)
at org.ldk.structs.Result_CVec_StrZIOErrorZ+Result_CVec_StrZIOErrorZ_OK..ctor(System.Object, Int64)
at org.ldk.structs.Result_CVec_StrZIOErrorZ.constr_from_ptr(Int64)
at org.ldk.structs.KVStore.list(System.String, System.String)
Matt Corallo [Thu, 1 Feb 2024 17:31:45 +0000 (17:31 +0000)]
[C#] Use `Heap{Alloc,Free}` rather than `malloc`/`free` on Windows
We generally expect to allocate pointers in C which Rust will free,
and vice versa. On Windows, this requires that we use the same
allocation path as Rust's stdlib does, which is actually
`Heap{Alloc,Free}`, not `malloc`/`free`. Here, we swap the heap
allocation functions we call, fixing heap corruption issues on
Windows.
Matt Corallo [Tue, 23 Jan 2024 21:19:51 +0000 (21:19 +0000)]
[C#] Use an instance of the callback delegate, not the fn itself
When passing the callback delegate to C from C# during static init,
it appears (but only on Windows) this actually creates a C# class
instance for the delegate and passes that. However, that class
instance is eventually GC'd and our callbacks will start failing.
Instead, we create a static instance of of the delegate and pass
that to C.
Matt Corallo [Tue, 7 Nov 2023 23:25:37 +0000 (23:25 +0000)]
[C#] Drop marshalling generation
Given we now do array/string conversion using the TypeScript logic
we no longer need to use the C# marshalling nonsense, which we
remove the remnants of here.
Matt Corallo [Tue, 7 Nov 2023 23:22:44 +0000 (23:22 +0000)]
[C#] Move C# side to a TypeScript-based array/string conversion
Using the marshallers properly will be a ton of additional work,
and its not clear we can do it in the C -> C# direction anyway.
Instead, we can trivially just use the TypeScript conversion logic
which converts everything through pointers anyway.
We'd previously done this on the C side of things, but here we do
it on the C# side as well.
Matt Corallo [Tue, 7 Nov 2023 18:30:10 +0000 (18:30 +0000)]
[C#] Rewrite trait impl based on typescript, not Java
C# doesn't let us pass arbitrary C# objects over the FFI as a
pointer, at least not easily, so instead we need something that
looks much more like what we do for TypeScript.
Here we rewrite the trait handling in C# based on the TypeScript
code and instead store weak pointers so we can reference trait
implementation instances by a single `long`.
Matt Corallo [Tue, 5 Sep 2023 03:00:37 +0000 (03:00 +0000)]
[C#] Use TypeScript Array/String layouts
C# doesn't have a way to pass arrays with a length, so we simply
re-use the TypeScript Array/String passing, which will be usable
with a CustomMarshaler on the C# side.
Matt Corallo [Tue, 5 Sep 2023 00:13:34 +0000 (00:13 +0000)]
[C#] Add missing handling of traits with supertraits of supertraits
In 831ad69f1f65d26c224fe18003f1694806effa5a support was added for
handling traits with supertraits of supertraits, but the full patch
was not applied to the C# bindings, which is finished here.
Matt Corallo [Mon, 31 Jul 2023 18:02:20 +0000 (18:02 +0000)]
Switch to playwright nightly to fix FF on Debian 12
It appears when playwright officially added support for Debian 12
(https://github.com/microsoft/playwright/issues/23532) they also
started throwing an error when trying to run unsupported browsers
on it (which Firefox was in the latest release). This broke our CI
(even though Firefox ran just fine on Debian 12 for the past year).
Here we simply switch to playwright nightly, which we'll just stick
with for a while.