zenoh icon indicating copy to clipboard operation
zenoh copied to clipboard

Plugin compatibility checking uses non-ABI-stable types

Open Nemo157 opened this issue 7 months ago • 1 comments

Describe the bug

When loading a plugin the loader and plugin assume that the zenoh_plugin_trait::Compatibility type is ABI-stable enough to pass between arbitrary versions to then verify if they are compatible.

This type is itself repr(C), but it contains repr(Rust) types:

https://github.com/eclipse-zenoh/zenoh/blob/2f955cc8749a8451d193eb4b4060e46e30165804/plugins/zenoh-plugin-trait/src/compatibility.rs#L57-L66

There's a few potentially unstable type layouts here and in sub-types:

  • &'static str: still undefined, it may be e.g. (len, ptr) or (ptr, len)
  • Option<RustcVersion>/Option<PluginStructVersion>: both of these sub-structs, while being repr(C), contain multiple fields with niches, the Option discriminant may be packed in different niches, or kept as a separate tag field. If stored as a tag field the byte value used may be different in different compilations.

To reproduce

Probably requires compiling with different compiler versions with different niche heuristics and/or -Zbuild-std/-Zrandomize-layout. I'm not certain there are existing compilers that have different enough behavior to trigger these problems, but they're at least allowed by the current specifications.

System info

irrelevant

Nemo157 avatar May 20 '25 10:05 Nemo157

Agree with you. This is confirmed here https://users.rust-lang.org/t/repr-c-on-nested-structs/110654 This should be fixed together with this task I suppose: https://github.com/eclipse-zenoh/zenoh/issues/1745

milyin avatar May 21 '25 10:05 milyin