@Alex Crichton, @Dan Gohman, I think I found a bug but I don't know exactly where things are going wrong: I hash the contents of a file and emit the result, but the result is different when I run the program as a rustc-compiled binary and as a wasm32-wasi file run in Wasmtime. Any ideas?
I created an example here: https://github.com/abrown/hashing-example
hm that repo is a 404, but what hash algorithm are you using?
sorry, just made it public
ah yeah the Hash
trait is not architecture-independent
it hashes usize
differently on 32 and 64-bit platforms
ooooh
so if I get rid of the trait and do the hashing manually I should get the same result, right?
you should yeah
hooray! solved.
thanks, deleting the repo now :smile:
Where does it hash a usize
? Does Hash
implicitly hash the length of a slice?
Aha, perhaps it does: https://doc.rust-lang.org/stable/src/core/hash/mod.rs.html#669
Which suggests that a way to avoid that would be to call hash_slice
instead.
ah yeah it's in hashing slices which hashes the length
Last updated: Dec 23 2024 at 12:05 UTC