Skip to content

Fix UBSan report in arraySlice and substring - #19459

Merged
alexey-milovidov merged 3 commits into
masterfrom
array-slice-ubsan
Jan 23, 2021
Merged

alexey-milovidov merged 3 commits into
masterfrom
array-slice-ubsan

Conversation

@robot-clickhouse robot-clickhouse added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jan 22, 2021
@alexey-milovidov alexey-milovidov changed the title Fix UBSan report in arraySlice Fix UBSan report in arraySlice and substring Jan 22, 2021
@@ -0,0 +1 @@
SELECT arraySlice(groupArray(x), -9223372036854775808, NULL) AS y FROM (SELECT '6553.5', uniqState(NULL) AS x FROM numbers(3) GROUP BY number);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also UB for select arraySlice([], -9223372036854775808) (in sliceDynamicOffsetUnbounded)

@azat

azat commented Jan 22, 2021

Copy link
Copy Markdown
Member

I have similar patch, likely I did not submit PR yet, but I noticed one more UB:

SELECT toIntervalMinute(9223372036854775807); -- INT64_MIN+1
SELECT toIntervalMinute(9223372036854775808); -- INT64_MIN

Looks like it is OK to add NO_SANITIZE_UNDEFINED for this function.

https://clickhouse-test-reports.s3.yandex.net/19381/95c9e57ec13e450ec6535cf723f504a2e68e3e2c/fuzzer_ubsan/report.html#fail1

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Could you please submit the PR nevertheless?
I will integrate the changes...

Yes, it's Ok to add NO_SANITIZE_UNDEFINED.

azat added a commit to azat/ClickHouse that referenced this pull request Jan 22, 2021
- arraySlice([], INT64_MIN) -- FunctionArraySlice::executeImpl

Found with fuzzer [1].

  [1]: https://clickhouse-test-reports.s3.yandex.net/19378/2c42600cf9bd8e9962b5b5a0ebb4bf11a10887ea/fuzzer_ubsan/report.html#fail1

v2: removed fixes that is already included into ClickHouse#19459
    - arraySlice(groupArray([]), INT64_MIN) -- sliceDynamicOffsetUnbounded
@azat

azat commented Jan 22, 2021 •

Copy link
Copy Markdown
Member

Could you please submit the PR nevertheless?

Sure - #19466

P.S. I've removed bits that you have already addressed

@alexey-milovidov alexey-milovidov self-assigned this Jan 23, 2021
@alexey-milovidov
alexey-milovidov merged commit 474ff29 into master Jan 23, 2021
@alexey-milovidov
alexey-milovidov deleted the array-slice-ubsan branch January 23, 2021 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants