-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] The plugin example in the tutorial reports a WARNING: "Result<Plugin, String>" is not FFI-safe. #68
Comments
Hi, Thanks for pointing out that issue.
Technically, this is not supported by the C ABI as ZSTs are illegal constructs in C. While this shouldn't cause issues due to the entire enum being non-ZST, it is possible that a poor implementation of the ABI may behave weirdly if it tries to decompose the type into its fields. More worrying was that the previous implementation let rustc keep thinking of padding byte repurposed into determinants as padding bytes. Since reading/writing in padding bytes is UB, this was a big soundness hole in Luckily, the solution to that issue also addresses yours: I'm still investigating some errors that |
Many thanks for your insightful response and great work on this project! |
You can already give that version a try by specifying a git dependency: stabby = {git="https://github.com/ZettaScaleLabs/stabby.git", branch="enum-improvements"} I'll probably release it as |
It works fine! All warnings have disappeared! Now I have confidence to use Stabby in a real project :) I think Stabby is the best crate for ABI stability according to my preferences because of its clean and intuitive API design and especially good support for async functions. I'm looking forward to the new release that resolves the UB issues. |
I found that Stabby cannot be compiled in Rust 1.78 (stable channel). Perhaps this information can help you in addressing the UB issues. Related comment: rust-lang/rust#121250 (comment) |
Ohhhh nooo... I was very afraid of that. A few months ago Namely, if an interiorly mutable value were to be referenced in a This is only a problem if that referenced value is interiorly mutable, which This means that as of today, there is no known way for Now is the time for bargaining with the Core Team: either they revert the interior mutability check until |
Of note: if you use I'll start experimenting with potential alternatives in the meantime; but having already fought this issue in the past, I can't promise I'll find a solution that works on |
Hiya @xuchaoqian, Just letting you know that if you Note that this workaround is way costlier than the implements in The current implementation of the workaround is "trivial": the set is implemented as an unordered vector, where:
I'll try to make a better implementation for this thread-safe global set by the release this weekend. I'm thinking of an atomic BTreeMap which would make lookups latencies more predictable and reduce the risk of insertion conflicts in concurrent situations. |
Oh, I really appreciate your efforts in solving this problem. If the cost is too expensive, I'll just use the nightly until |
Great :) I'd really appreciate any feedback you can provide on the performance :) I'll make a new issue to track this 1.78 breakage, as this issue has crept out of scope completely :) |
Stabby is a great crate, especially because it supports futures & trait objects. I have made a demo to show this.
See here: stabby-plugin-demo.
Now I get some weird issues. It seems that the implementation of "Result and Option" has some bugs now. @p-avital
Reproduction steps for "Result" issue:
1. git clone https://github.com/xuchaoqian/stabby-example.git
2. cd stabby-example/plugin-a && cargo build
3. then we will get the WARNING as the following:
Reproduction steps for "Option" issue:
if we change "Result<Plugin, String>" to "stabby::option::Option<Plugin>" like following:
then we will get a similar WARNING:
The text was updated successfully, but these errors were encountered: