Someone's made a safe abstraction for writing lock-free data structures. Should we maybe assemble a list of such things? I just randomly stumble upon these. Once I feel I can't make my code fast without
unsafe there is no repository of existing safe abstractions that would maybe solve my problem
I think that's a good idea. What do other folks think? It'd be nice if there were a single place to go when you want to do something unsafe and you're wondering whether there's a crate that does it for you.
Yes, I think that'd be super helpful.
I think we could definitely use some lists of recommended crates
I just stumbled upon this crate, might be worth keeping an eye out for: https://crates.io/crates/unsafesc
A safe-ish abstraction for
Are you planning to implement alignment checks?
FYI armv6 says that unaligned access is unpredictable. https://medium.com/@iLevex/the-curious-case-of-unaligned-access-on-arm-5dd0ebe24965
This isn't my crate :slight_smile: But I'm guessing that's why the authors didn't implement alignment checks, since they support
Plus, I wouldn't know how to.
unaligned accesses are UB in LLVM, so it doesn't really matter what the HW does, your code could already get misoptimized before than. or is this about assembly code?
Uh.... that crate has tons of soundness problems
like, I can transmute
&u32 and alignment is not checked -> insta-UB
Also they seem to transmute
Thanks for pointing that out @RalfJ. I'm not competent enough to validate it's soundness. I wasn't aware that it was in such a bad shape... At least it's now clear that this should not be included in a list of recommended safe abstractions!
TBH I can only recommend to stay away from that crate^^
I'll stop after finding one concrete example of unsoundness: https://github.com/nabijaczleweli/safe-transmute-rs/issues/35
haha, I'm a little taken aback by "safe" and "transmute" appearing in succession
also I really like how clippy tells you which transmutes can be replaced with pointer casts
not that pointer casts are all that great either, but they seem marginally safer