-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add validation functions and fixup sanitizer build (#73)
* Make sure that ASAN is linked in When UBSan is enabled the equivalent flag is already added to the link options and the UBSan runtime gets linked in, but when enabling ASAN the build fails because it can't find a lot of symbols. The fix is to link it if you use it. * Remove unnecessary compile definition ASAN_OPTIONS is a runtime environment variable and doesn't affect compilation (unless exported as the symbol __asan_default_options, which it isn't here). Also note that enabling detect_leaks breaks macOS since AppleClang doesn't support this (though the LLVM from brew does). * Fix leaks spotted by the sanitizers * Fix Makefile for unit unit makes use of streamvbyte_isadetection.h which is in an internal header not in the public API. * Typo copypasta fix * Add stream validation functions These are useful when loading untrusted data since it's typically trivial to change the uncompressed size that's stored alongside the encoded data. Doing so can cause the decode functions to read past the end of the input data, which at best generates bad output and at worst causes crashes if it happens to read into an unmapped page. * Add missing newlines from print statements These presumably always passed so were never printed. Also include the iteration for easier debugging. * Silence MSVC warnings about possible loss of data The encode functions return size_ts so we should match that. * Change data initialisation in unit tests All the data would be about the same value [gap-1, gap+6] and wouldn't border on a byte width meaning that all of the keys would be the same and hence wouldn't catch bugs when reading the wrong keys. Instead use the gap to space the elements apart. * Improve performance of streamvbyte_validate_stream AppleClang 16 doesn't appear to be clever enough to transform the loop into a branchless one, so help it out by adding a loop that it knows how to unroll. Also do the same for streamvbyte_validate_stream_0124 though I haven't tested the performance of that. * Add NEON implementation of validate Nothing fancy, just processing 4 keys per vector. In both micro- and macro-benchmarks this performs at basically the same speed as the loop added in the previous commit (tested with clang), both of which are significantly faster than the original version. * Document the validate functions in the README
- Loading branch information
1 parent
dd95854
commit 0934b51
Showing
10 changed files
with
186 additions
and
14 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
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