Closed lukbukkit closed 2 months ago
Can you clarify why you believe that this crash is related to swift-bridge
?
Hi, you're probably correct that the cause of the crash is unrelated to swift-bridge
. Where would you recommend reporting this issue? Is the rust-lang/rust repository the correct place?
Does the program crash if you write to stdout from Swift instead of Rust?
No, Swift's internal print
function does not cause a crash in these conditions. I've updated the example repository with comments to highlight the line that causes the crash.
Where would you recommend reporting this issue?
Hard to say without knowing the root cause.
You can do the following:
Add a pub extern "C" fn print_hello() { println!("hello") }
to your Rust library. https://github.com/lukbukkit/swift-rust-bridge-println/blob/main/src/lib.rs
Add a void print_hello(void);
to your BridgingHeader.h
https://github.com/lukbukkit/swift-rust-bridge-println/blob/main/SwiftRustBridgePrintln/BridgingHeader.h
Replace your call to rust.hello()
with a call to print_hello()
rustApp.rust.hello().
This will make us sure about whether swift-bridge
is involved.
If the println!
panics, you can try going even more minimal and just writing a string to stdout
and seeing if that panics.
std::io::stdout().write_all(b"hello world").unwrap();
Hi,
Thanks for this great library. I've discovered a reproducible crash partly in connection to this library. The invocation of
println!
in Rust causes a panic (and a crash if not caught) if Xcode launches an iOS app with an enabled debug connection, but then the connection is lost.Steps To Reproduce
SwiftRustBridgePrintln/SwiftRustBridgePrintln.xcodeproj
Screenshot
Versions
macOS: Sonoma 14.6.1 Xcode: 15.4 iOS: 17.6.1
rustc: 1.18.0 swift-bridge: 0.1.57