gz / rust-cpuid

cpuid library in rust.
https://docs.rs/raw-cpuid/
MIT License
154 stars 45 forks source link

Serialization issue #87

Closed IsaacDynamo closed 1 year ago

IsaacDynamo commented 2 years ago

I don't use the serialize feature my self but the following use-case seems broken:

Structs with a CpuIdReader member will return a mix of machine A and B features.

For example a RdtMonitoringInfo serialized on machine A and deserialized on machine B will return a mix of info. RdtMonitoringInfo::rmid_range() will return machine A info while RdtMonitoringInfo::l3_monitoring() will return machine B info.

gz commented 2 years ago

Agreed! I fear this will likely happen in more places than just RdtMonitoringInfo.

A better solution for serialization/deserialization would probably be to just make CpuId serializeable (by reading all possible/reachable cpuid leafs) and storing/shipping that in a Vec<Vec<CpuIdResult>>. On deserialization a CpuId can be instantiated with with_cpuid_fn or similar function that then just reads from the Vec<Vec<CpuIdResult>>.

gz commented 2 years ago

Luckily I don't think there are many users of the serialize feature yet.