From 421861958283f956c6202e8c03ffb79258ab3c96 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 9 May 2016 14:05:43 -0700 Subject: [PATCH] folly test: fix typo in RandomDataHolder::RandomDataHolder Summary: Running the folly/io/test:compression_test with a UBSAN-enabled binary would fail with this: folly/io/test/CompressionTest.cpp:96:36: runtime error: shift exponent 16777216 is too large for 64-bit type 'size_t' (aka 'unsigned long') That exposed the unwanted left-shift. That made it so the actual "start" offsets were in the range [0..numThreads-1], rather than being e.g., with numThreads == 8, [0, 16777216, 33554432, ...]. Oops. Reviewed By: luciang Differential Revision: D3277606 fbshipit-source-id: 4bc48f84b0065de070b62a810f08b96e36ea7136 --- folly/io/test/CompressionTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/folly/io/test/CompressionTest.cpp b/folly/io/test/CompressionTest.cpp index 020d7487..8fe347f1 100644 --- a/folly/io/test/CompressionTest.cpp +++ b/folly/io/test/CompressionTest.cpp @@ -92,7 +92,7 @@ RandomDataHolder::RandomDataHolder(size_t sizeLog2) threads.emplace_back( [this, seed, t, numThreadsLog2, sizeLog2] () { std::mt19937 rng(seed + t); - size_t countLog2 = size_t(1) << (sizeLog2 - numThreadsLog2); + size_t countLog2 = sizeLog2 - numThreadsLog2; size_t start = size_t(t) << countLog2; for (size_t i = 0; i < countLog2; ++i) { this->data_[start + i] = rng(); -- 2.34.1