(ask me how to reproduce)
```
2020.07.21 13:02:17.136627 [ 50994 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregating
2020.07.21 13:02:17.136666 [ 50994 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> Aggregator: Aggregation method: serialized
2020.07.21 13:02:17.138054 [ 51017 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregating
2020.07.21 13:02:17.138087 [ 51017 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> Aggregator: Aggregation method: serialized
2020.07.21 13:02:17.141938 [ 48199 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregating
2020.07.21 13:02:17.141989 [ 48199 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> Aggregator: Aggregation method: serialized
2020.07.21 13:02:17.190867 [ 48376 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregating
2020.07.21 13:02:17.190896 [ 48376 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> Aggregator: Aggregation method: serialized
2020.07.21 13:02:17.244165 [ 51018 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregating
2020.07.21 13:02:17.244197 [ 51018 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> Aggregator: Aggregation method: serialized
2020.07.21 13:02:17.255410 [ 51021 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregating
2020.07.21 13:02:17.256577 [ 51021 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> Aggregator: Aggregation method: serialized
2020.07.21 13:02:17.320676 [ 48372 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregating
2020.07.21 13:02:17.320728 [ 48372 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> Aggregator: Aggregation method: serialized
2020.07.21 13:02:17.363163 [ 48229 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregating
2020.07.21 13:02:17.371836 [ 48229 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> Aggregator: Aggregation method: serialized
2020.07.21 13:02:17.428979 [ 48229 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregated. 4492 to 533 rows (from 515.63 KiB) in 0.311488059 sec. (14421.098562882631 rows/sec., 1.62 MiB/sec.)
2020.07.21 13:02:17.437747 [ 51018 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregated. 2652 to 441 rows (from 305.87 KiB) in 0.320386199 sec. (8277.510105858211 rows/sec., 954.69 KiB/sec.)
2020.07.21 13:02:17.439813 [ 48372 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregated. 6741 to 614 rows (from 775.87 KiB) in 0.322366181 sec. (20911.00244786534 rows/sec., 2.35 MiB/sec.)
2020.07.21 13:02:17.483090 [ 50994 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregated. 12427 to 764 rows (from 1.39 MiB) in 0.365789427 sec. (33973.097861027025 rows/sec., 3.80 MiB/sec.)
2020.07.21 13:02:17.490620 [ 51017 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregated. 7054 to 613 rows (from 812.47 KiB) in 0.365831276 sec. (19282.112992438626 rows/sec., 2.17 MiB/sec.)
2020.07.21 13:02:17.500578 [ 48199 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregated. 3608 to 478 rows (from 411.80 KiB) in 0.383044986 sec. (9419.259178085156 rows/sec., 1.05 MiB/sec.)
2020.07.21 13:02:17.504420 [ 48376 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregated. 7210 to 660 rows (from 827.06 KiB) in 0.387015092 sec. (18629.764443397984 rows/sec., 2.09 MiB/sec.)
2020.07.21 13:02:17.506544 [ 51021 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> AggregatingTransform: Aggregated. 2396 to 431 rows (from 272.98 KiB) in 0.38910647 sec. (6157.697660488658 rows/sec., 701.54 KiB/sec.)
2020.07.21 13:02:17.506575 [ 51021 ] {d3b9634c-0710-48f1-8456-7aa84cf5f396} <Trace> Aggregator: Merging aggregated data
2020.07.21 13:02:17.573203 [ 51394 ] {} <Fatal> BaseDaemon: ########################################
2020.07.21 13:02:17.573327 [ 51394 ] {} <Fatal> BaseDaemon: (version 20.6.2.1 (official build), no build id) (from thread 51021) (query_id: d3b9634c-0710-48f1-8456-7aa84cf5f396) Received signal Segmentation fault (11)
2020.07.21 13:02:17.573377 [ 51394 ] {} <Fatal> BaseDaemon: Address: 0xfffffffffffffff0 Access: read. Address not mapped to object.
2020.07.21 13:02:17.573415 [ 51394 ] {} <Fatal> BaseDaemon: Stack trace: 0xe9aaf3d 0xe92ea10 0xf1f97c5 0xefc5ce3 0xeffbaa1 0xf0013c6 0xf002714 0x98c8f47 0x98c7483 0x7f08aa26d184 0x7f08a9b8e03d
2020.07.21 13:02:17.574139 [ 51394 ] {} <Fatal> BaseDaemon: 3. /build/obj-x86_64-linux-gnu/../src/Columns/ColumnTuple.cpp:352: DB::ColumnTuple::updatePermutation(bool, unsigned long, int, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 15ul, 16ul>&, std::__1::vector<std::__1::pair<unsigned long, unsigned long>, std::__1::allocator<std::__1::pair<unsigned long, unsigned long> > >&) const @ 0xe9aaf3d in /usr/lib/debug/usr/bin/clickhouse
2020.07.21 13:02:17.575848 [ 51394 ] {} <Fatal> BaseDaemon: 4. /build/build_docker/../src/Interpreters/sortBlock.cpp:211: DB::sortBlock(DB::Block&, std::__1::vector<DB::SortColumnDescription, std::__1::allocator<DB::SortColumnDescription> > const&, unsigned long) @ 0xe92ea10 in /usr/lib/debug/usr/bin/clickhouse
2020.07.21 13:02:17.576881 [ 51394 ] {} <Fatal> BaseDaemon: 5. /build/obj-x86_64-linux-gnu/../src/Processors/Transforms/PartialSortingTransform.cpp:125: DB::PartialSortingTransform::transform(DB::Chunk&) @ 0xf1f97c5 in /usr/lib/debug/usr/bin/clickhouse
2020.07.21 13:02:17.577610 [ 51394 ] {} <Fatal> BaseDaemon: 6. /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/type_traits:3695: DB::ISimpleTransform::work() @ 0xefc5ce3 in /usr/lib/debug/usr/bin/clickhouse
2020.07.21 13:02:17.578408 [ 51394 ] {} <Fatal> BaseDaemon: 7. /build/build_docker/../src/Processors/Executors/PipelineExecutor.cpp:167: std::__1::__function::__func<DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::'lambda'(), std::__1::allocator<DB::PipelineExecutor::addJob(DB::PipelineExecutor::ExecutionState*)::'lambda'()>, void ()>::operator()() @ 0xeffbaa1 in /usr/lib/debug/usr/bin/clickhouse
2020.07.21 13:02:17.579791 [ 51394 ] {} <Fatal> BaseDaemon: 8. /build/build_docker/../contrib/libcxx/include/exception:180: DB::PipelineExecutor::executeStepImpl(unsigned long, unsigned long, std::__1::atomic<bool>*) (.constprop.0) @ 0xf0013c6 in /usr/lib/debug/usr/bin/clickhouse
2020.07.21 13:02:17.581397 [ 51394 ] {} <Fatal> BaseDaemon: 9. /build/build_docker/../src/Processors/Executors/PipelineExecutor.cpp:798: ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PipelineExecutor::executeImpl(unsigned long)::'lambda0'()>(DB::PipelineExecutor::executeImpl(unsigned long)::'lambda0'()&&)::'lambda'()::operator()() const @ 0xf002714 in /usr/lib/debug/usr/bin/clickhouse
2020.07.21 13:02:17.581706 [ 51394 ] {} <Fatal> BaseDaemon: 10. /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/atomic:856: ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0x98c8f47 in /usr/lib/debug/usr/bin/clickhouse
2020.07.21 13:02:17.581832 [ 51394 ] {} <Fatal> BaseDaemon: 11. /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:2615: void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda1'()> >(void*) @ 0x98c7483 in /usr/lib/debug/usr/bin/clickhouse
2020.07.21 13:02:17.581884 [ 51394 ] {} <Fatal> BaseDaemon: 12. start_thread @ 0x8184 in /lib/x86_64-linux-gnu/libpthread-2.19.so
2020.07.21 13:02:17.581952 [ 51394 ] {} <Fatal> BaseDaemon: 13. __clone @ 0xfe03d in /lib/x86_64-linux-gnu/libc-2.19.so
```
{
    const size_t tuple_size = columns.size();
    std::vector<MutableColumns> scattered_tuple_elements(tuple_size);
    for (size_t tuple_element_idx = 0; tuple_element_idx < tuple_size; ++tuple_element_idx)
        scattered_tuple_elements[tuple_element_idx] = columns[tuple_element_idx]->scatter(num_columns, selector);
    MutableColumns res(num_columns);
    for (size_t scattered_idx = 0; scattered_idx < num_columns; ++scattered_idx)
    {
        MutableColumns new_columns(tuple_size);
        for (size_t tuple_element_idx = 0; tuple_element_idx < tuple_size; ++tuple_element_idx)
            new_columns[tuple_element_idx] = std::move(scattered_tuple_elements[tuple_element_idx][scattered_idx]);
        res[scattered_idx] = ColumnTuple::create(std::move(new_columns));
    }
    return res;
}
int ColumnTuple::compareAt(size_t n, size_t m, const IColumn & rhs, int nan_direction_hint) const
{
    const size_t tuple_size = columns.size();
    for (size_t i = 0; i < tuple_size; ++i)
        if (int res = columns[i]->compareAt(n, m, *assert_cast<const ColumnTuple &>(rhs).columns[i], nan_direction_hint))
            return res;
    return 0;
}
void ColumnTuple::compareColumn(const IColumn & rhs, size_t rhs_row_num,