uniffi-rs
uniffi-rs copied to clipboard
Attempt to use a default method for a trait crashes with SIGSEGV
trafficstars
With the patch below, the Python test crashes with fish: Job 1, 'PYTHONPATH=/Users/skip/src/moz/…' terminated by signal SIGSEGV (Address boundary error)
(When running the test you just see a failure but no output - to see the output I needed to run PYTHONPATH=target/tmp/uniffi_proc_macro-xxx python fixtures/proc-macro/tests/bindings/test_proc_macro.py)
The patch:
diff --git a/fixtures/proc-macro/src/lib.rs b/fixtures/proc-macro/src/lib.rs
index 9d1f18b4ce..141199737d 100644
--- a/fixtures/proc-macro/src/lib.rs
+++ b/fixtures/proc-macro/src/lib.rs
@@ -58,6 +58,10 @@
// incompatible with callback interfaces
#[allow(clippy::ptr_arg)]
fn concat_strings(&self, a: &str, b: &str) -> String;
+
+ fn optional(&self) -> String {
+ "trait".to_string()
+ }
}
struct TraitImpl {}
diff --git a/fixtures/proc-macro/tests/bindings/test_proc_macro.py b/fixtures/proc-macro/tests/bindings/test_proc_macro.py
index 6148f91dff..65625ec9d6 100644
--- a/fixtures/proc-macro/tests/bindings/test_proc_macro.py
+++ b/fixtures/proc-macro/tests/bindings/test_proc_macro.py
@@ -32,6 +32,7 @@
assert concat_strings_by_ref(trait_impl, "foo", "bar") == "foobar"
assert issubclass(StructWithTrait, Trait)
assert StructWithTrait("me").concat_strings("foo", "bar") == "me: foobar"
+assert StructWithTrait("").optional() == "trait"
trait_impl2 = obj.get_trait_with_foreign(None)
# This is an instance of `TraitWithForeignImpl` - `TraitWithForeign` is used primarily for subclassing.
~