-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[crc64] Fix a subtle bug in CRC64 splice-by-8 implementation (#627)
Commit 9b88ce7 implemented a splice-by-8 version of the CRC64 algorithm which processes 8 bytes per loop iteration. However, the code had a subtle bug which resulted in the same CRC calculated for different strings and made some of the Xamarin.Android tests to fail. The following strings yielded the same checksum value: * `obj/Debug/lp/10/jl/bin/classes.jar` * `obj/Debug/lp/11/jl/bin/classes.jar` * `obj/Debug/lp/12/jl/bin/classes.jar` The reason for this was subtle (a stupid oversight on my part, really): the loop fetched values from the input array by using an index into the array: crc ^= (ulong)aptr[idx]; However, with `aptr` being declared as `byte* aptr` the indexing operation returned a single *byte* instead of the required 64-bit word (8 bytes) and, thus, on each iteration of the loop 7 bytes of the input arrays were ignored in calculation, thus causing the collisions. The fix is to cast `aptr` to `ulong*` and *then* index it, extracting the required 8 bytes. This commit also adds a test to check for this issue.
- Loading branch information
Showing
5 changed files
with
60 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters