add C API for epoch_deadline_callback and wasmtime_error_t creation#6359
Conversation
c3d50e6 to
bae24ca
Compare
Subscribe to Label Actioncc @peterhuene DetailsThis issue or pull request has been labeled: "wasmtime:c-api"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
alexcrichton
left a comment
There was a problem hiding this comment.
Looks reasonable to me, thanks!
| Some(Box::new(wasmtime_error_t::from(anyhow!("{:?}", unsafe { | ||
| std::ffi::CStr::from_ptr(msg) | ||
| })))) | ||
| } |
There was a problem hiding this comment.
I think instead of :? this should use .to_str() on the pointer received to avoid Rust-level string escaping which shows up in the debug representation.
There was a problem hiding this comment.
.to_str() leaves me with the potential to get a Utf8Error instead of a &str. I was not sure what the preferred way to deal with such bad input would be, but based on what I see in crates/c-api/src/trap.rs, I think I will go with String::from_utf8_lossy(). Sound good?
There was a problem hiding this comment.
Yeah I think the _lossy variant is fine. That's a reality of working with cross-language FFI here but in the context of "just an error message" the lossy variant should be fine.
There was a problem hiding this comment.
Thanks, revised.
|
Hi! From my testing, it seems the new I would have expected a similar behavior as Thanks! |
|
Ah thanks for testing! That's a mistake in the API and a subtle detail with the implementation. It's definitely not intended that the pointer should remain live, the contents should be copied into the error. The line that needs to change is this one, namely the |
|
🤦 Sorry, that's my Rust newbieness showing. I missed that |
issue #6277
This adds C API interfaces to: