Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nfa::contiguous::tests::swar test failure on s390x (and possibly all big-endian architectures) #117

Closed
decathorpe opened this issue May 29, 2023 · 3 comments

Comments

@decathorpe
Copy link

I'm maintaining the Fedora Linux package for this crate, and upon the update from v0.7 to v1.0, I see new test failure on s390x / IBM System Z (i.e. s390x-unknown-linux-gnu):

failures:
---- nfa::contiguous::tests::swar stdout ----
thread 'nfa::contiguous::tests::swar' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `3`', src/nfa/contiguous.rs:1116:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
    nfa::contiguous::tests::swar

Looking at the code for this test, it's not surprising that it might fail on systems with big-endian byte order, given that most constants are hard-coded hex literals, and the function relies heavily on bitmasks / bitshifts / etc.

Reading the comment above the test, it sounds like this functionality isn't actually used in the aho-corasick crate but only kept "for posterity"? I will ignore the failure for now, but it might make sense to document that this code doesn't work as expected on big-endian architectures, or gate it behind something like #[cfg(target_endian = "little")]?

BurntSushi added a commit that referenced this issue Jun 4, 2023
The 'swar' test is apparently sensitive to endianness. The test is just
about demonstrating a technique I had tried but didn't work out for perf
reasons. It's good to keep it, but let's just gate it on little-endian
targets.

Fixes #117
@BurntSushi
Copy link
Owner

Thanks! Yeah, this doesn't impact the "real" code.

Like #116, this also should have been caught by CI. Namely, CI includes mips64-unknown-linux-gnuabi64, which tests on big-endian. Running tests locally results in a failure. So I'm not sure why this wasn't caught.

@BurntSushi
Copy link
Owner

It was me being dumb. I wasn't passing $TARGET to the Cargo build commands, so while cross was running, it was just using the host target.

@decathorpe
Copy link
Author

Great, thanks for confirming!

And well, at any rate, the CI should be more robust now 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants