• yoav-steinberg's avatar
    Fix possible int overflow when hashing an sds. (#9916) · c7dc17fc
    yoav-steinberg authored
    This caused a crash when adding elements larger than 2GB to a set (same goes for hash keys). See #8455.
    
    Details:
    * The fix makes the dict hash functions receive a `size_t` instead of an `int`. In practice the dict hash functions
      call siphash which receives a `size_t` and the callers to the hash function pass a `size_t` to it so the fix is trivial.
    * The issue was recreated by attempting to add a >2gb value to a set. Appropriate tests were added where I create
      a set with large elements and check basic functionality on it (SADD, SCARD, SPOP, etc...).
    * When I added the tests I also refactored a bit all the tests code which is run under the `--large-memory` flag.
      This removed code duplication for the test framework's `write_big_bulk` and `write_big_bulk` code and also takes
      care of not allocating the test frameworks helper huge string used by these tests when not run under `--large-memory`.
    * I also added the _violoations.tcl_ unit tests to be part of the entire test suite and leaned up non relevant list related
      tests that were in there. This was done in this PR because most of the _violations_ tests are "large memory" tests.
    c7dc17fc
util.tcl 28.8 KB