Merge pull request #19460 from ClickHouse/running-difference-ubsan

Fix UBSan report in runningDifference
This commit is contained in:
alexey-milovidov 2021-01-23 12:02:48 +03:00 committed by GitHub
commit bbaa0786d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 1 deletions

View File

@ -46,7 +46,7 @@ private:
/// It is possible to track value from previous columns, to calculate continuously across all columnss. Not implemented.
template <typename Src, typename Dst>
static void process(const PaddedPODArray<Src> & src, PaddedPODArray<Dst> & dst, const NullMap * null_map)
static NO_SANITIZE_UNDEFINED void process(const PaddedPODArray<Src> & src, PaddedPODArray<Dst> & dst, const NullMap * null_map)
{
size_t size = src.size();
dst.resize(size);
@ -76,6 +76,7 @@ private:
else
{
auto cur = src[i];
/// Overflow is Ok.
dst[i] = static_cast<Dst>(cur) - prev;
prev = cur;
}

View File

@ -0,0 +1 @@
SELECT k, d, i FROM (SELECT t.1 AS k, t.2 AS v, runningDifference(v) AS d, runningDifference(cityHash64(t.1)) AS i FROM (SELECT arrayJoin([(NULL, 65535), ('a', 7), ('a', 3), ('b', 11), ('b', 2), ('', -9223372036854775808)]) AS t)) WHERE i = 9223372036854775807;