Comments (7)
I ran all the tests on my side and looks great.
from crc32c.
I am pretty sure the issue comes from some edge case with endianess. PowerPC has 3 different architectures:
- PowerPC, big endian 32 bit
- PowerPC 64, big endian 32 bit
- PowerPC 64le, little endian 64 bit and 64
Tests against PowerPC 64le are passing:
❯❯❯ ~/github/crc32c ❯ cross test --target powerpc64le-unknown-linux-gnu
warning: unused manifest key: target.aarch64-unknown-linux-gnu.linker
Finished test [unoptimized + debuginfo] target(s) in 0.16s
Running unittests src/lib.rs (/target/powerpc64le-unknown-linux-gnu/debug/deps/crc32c-27d21e5a67b97edc)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/simple.rs (/target/powerpc64le-unknown-linux-gnu/debug/deps/simple-5fe61d7c8ac92f28)
running 6 tests
test crc ... ok
test crc_append ... ok
test crc_combine ... ok
test long_string ... ok
test very_big ... ok
test very_small ... ok
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s
from crc32c.
might the issue be here?:
Line 33 in 47c2999
util::split
takes a &[u8]
, and one of its return values is a &[u64]
, meaning it's transmuting the two without considering endianness.
edit: (this is called in the software impl here:
Line 24 in 47c2999
from crc32c.
Hum this is a good hunch.. Writing unsafe
rust is hard :) I am not sure how to try to fix this thou.. There are other people lamenting that mem::transmute
is of course not doing the right thing on BE: https://users.rust-lang.org/t/std-mem-transmute-returns-different-values-between-architectures/1589
from crc32c.
if this is the case, then some change needs to be made either in this function or at callsites (or both).
u64::from_le
may be useful here; if callsites using this slice, whenever they need elements, pass them through that, it may be correct?
expanding further on the previous points, util::split
could return &[U64Le]
(fixing this on the type-level) so it wouldn't have to be a manual conversion:
#[repr(transparent)]
#[derive(Clone, Copy)]
struct U64Le(u64);
impl U64Le {
#[inline]
pub const fn get(self) -> u64 {
u64::from_le(self.0)
}
}
which would be safe to transmute to in the original function because it has the same layout as a u64 with the repr(transparent)
.
from crc32c.
im trying this fix out, could you see if it works correctly on those big endian targets?
link: https://github.com/nissaofthesea/crc32c/tree/231fed8cb605ae4db02ab91ac164400ccf09a6ad
EDIT: didn't see you used cross
when i wrote this, so i installed that and tested it on this commit.
$ cross test --target powerpc-unknown-linux-gnu
warning: unused manifest key: target.aarch64-unknown-linux-gnu.linker
Finished test [unoptimized + debuginfo] target(s) in 0.09s
Running unittests src/lib.rs (/target/powerpc-unknown-linux-gnu/debug/deps/crc32c-52b9b02f194c0936)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/simple.rs (/target/powerpc-unknown-linux-gnu/debug/deps/simple-0ffe959d1ae05e6c)
running 6 tests
test crc ... ok
test crc_append ... ok
test crc_combine ... ok
test long_string ... ok
test very_big ... ok
test very_small ... ok
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.03s
seems to work, nice! i'll open a pull request then
from crc32c.
This is neat. Tomorrow I'll rerun all the tests I have on my side!
from crc32c.
Related Issues (20)
- Set a description / topics for the repository
- Set up continuous integration
- incorrect use of unsafe HOT 4
- Build crc32c for ARM HOT 2
- Doesn't build on x86
- UB in build script HOT 2
- UB when `util::split` returns zero-length slices HOT 1
- Maintain a CHANGELOG file
- Hasher Trait HOT 2
- 0.6.4 release? HOT 1
- Why ARM hardware acceleration is guarded by nightly HOT 4
- Crc32cHasher initial value should apply effect of refin
- Nightly build fails due to removal of the unstable `stdsimd` feature
- Fail to build on macOS M2 HOT 3
- Crate does not build on latest nightly due to stabilization of stdarch_arm_crc32
- Fail to build on macOS M1 HOT 4
- stdarch_arm_crc32 block nightly build, please release a new version HOT 2
- Rust 1.76: unsupported output in build script of `crc32c v0.6.6`: `cargo::rerun-if-changed=build.rs` HOT 9
- BROKEN BUILD HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crc32c.