-
Notifications
You must be signed in to change notification settings - Fork 140
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
Fix 575, regression tests #582
Conversation
e4d7cdd
to
33c4003
Compare
@Bodigrim - what version of QuickCheck gets pulled into our unusual architecture jobs? I'm also seeing some tests regarding lazy |
@kozross it's |
33c4003
to
7be4489
Compare
I'm getting a bunch of failures for lazy bytestring tests on both Windows and 64-bit ARM. The NetBSD tests are just not starting at all. Not sure how to fix either issue. |
I'm not sure what you mean by "failures for lazy bytestring tests on both Windows and 64-bit ARM." Are you seeing these locally? These are the only test failures I see in the CI logs: windows
arm64
The NetBSD job is indeed currently broken. I haven't seen this s390x failure before; I just tried restarting the job. |
@clyring - thanks for pointing that out to me: I thought the laziness stuff indicated failures due to exceptions. I'll try and repro those locally, but it's quite odd that these don't show up anywhere else. Edit: The ARM stuff isn't too surprising actually: I forgot to put the fix in the NEON code, but that shouldn't be difficult. |
@kozross if you rebase atop the latest master, NetBSD failure should go away. |
8ca5425
to
71cbb89
Compare
71cbb89
to
4c084d6
Compare
@Bodigrim - the NEON side of things is fixed now, using a similar fix to the SSE/AVX ones. However, the Windows issue is weird, and I'm unable to diagnose it. Here's what I can say for sure:
My best guess is that there's a subtle form of UB at play here which gets compiled differently on Windows than on Mac or Linux. However, this both seems unlikely, and is nearly impossible for me to verify: it's clearly not a Clang-versus-GCC issue, as 9.6 on Windows bundles Clang AFAICT, and the Mac build doesn't hit this problem. Thus, it means it's some kind of Clang version divergence in the non-SIMDed validation code, and as it currently stands, I don't even know what Clang version gets bundled with GHC 9.6.1 on Windows, and have no good way to check. If someone has access to a Windows machine, and some expertise with C-on-Windows-with-Clang, I'd appreciate the assistance, as I have neither. |
According to this comment, this might be Clang 15 haskell/cabal#8841 (comment) |
@kozross |
@kozross could you please rebase once more? And feel free to set |
Tests on Windows seem to fail because |
@sergv - thanks, that's an excellent catch! |
@Bodigrim - done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, many thanks!
Gross. Why isn't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(To be clear, my previous comment was an expression of frustration rather than a request for this patch. Thanks @sergv for spotting that; I was not looking forward to diagnosing it.)
@Bodigrim - yep, |
I'd rather rewrite to avoid strict-aliasing violations to begin with, but it doesn't make sense to hold up this patch over that. Let's add the flag to |
@clyring This flag is used fairly often, and a rewrite to fix this would be tedious and pointless. There's nothing per-se wrong with disabling this behaviour: the standard is not a goal in and of itself. |
@clyring good to go now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@clyring good to go now?
Yes. To quote myself:
Let's add the flag to cc-options and merge.
I'll create separate issues for the low-priority follow-up work.
* Refactor isValidUtf8 tests to enable shrinking * Test isValidUtf8 on strings which are almost valid, with long ranges of ASCII * Repair invalid UTF-8 issue, more tests * Fix NEON ASCII check * Refactor isValidUtf8 tests to enable shrinking * Test isValidUtf8 on strings which are almost valid, with long ranges of ASCII * Use ctzll to ensure 8 bytes get processed * Set -fno-strict-aliasing --------- Co-authored-by: Bodigrim <[email protected]>
Sorry for the long wait on this one folks. This fixes #575, as well as incorporating @Bodigrim's regression tests (which all pass, of course).
The reason this happened was a subtle mistake on my part. In brief, the way the SIMDed (both SSE and AVX) validator used to work is roughly as so:
a. Check speculatively if the entire block is ASCII.
b. If the entire block is ASCII, plough on.
c. Otherwise, check if the block is UTF-8.
d. Accumulate error
A key factor to making this work is the ability to 'preserve validation state' across strides: this means that, were we to have a stride where the last byte is the start of a multi-byte sequence, the validator is aware of this and can respond.
The issue I had to fix was that step 2a did two very naughty things:
alpha. Ignore the 'preserved state' from the previous stride entirely.
beta. Overwrite the 'preserved state' with a 'clean' one, indicating no carryover.
Thus, the issues observed previously. The checks for both SSE and AVX versions of speculative ASCII validation have been modified to take this into account. Near as I can tell, this has no impact on performance: the code was choked on memory movement (and the corresponding true dependencies), and register pressure was not increased by this change. I've added comments explaining exactly how both versions work in case someone else needs to maintain this code.
I also added an extra test to exclude the possibility that ASCII verification itself was broken (it wasn't).