https://s3.amazonaws.com/clickhouse-test-reports/38490/c24c041b1214345ab341726754d0f90bddb1095d/fuzzer_astfuzzerubsan,actions//report.html

```
2022.06.28 01:21:58.754707 [ 432 ] {} <Fatal> BaseDaemon: ########################################
2022.06.28 01:21:58.754786 [ 432 ] {} <Fatal> BaseDaemon: (version 22.7.1.1, build id: EF45FEAD681763DA) (from thread 428) (query_id: c8d8c025-3922-4030-ae47-87692c3f5415) (query: SELECT number, 1 AS k FROM numbers(100000) ORDER BY k ASC, number DESC LIMIT 1025, 1023 FORMAT Values) Received signal Unknown signal (-3)
2022.06.28 01:21:58.754820 [ 432 ] {} <Fatal> BaseDaemon: Sanitizer trap.
2022.06.28 01:21:58.754873 [ 432 ] {} <Fatal> BaseDaemon: Stack trace: 0xfe89d43 0x100f9071 0xfe3da06 0xfe5260d 0x243c9aad 0x254f1db1 0x254f0c8b 0x1d45a70b 0x25118351 0x2513f740 0x2513f317 0x251318f3 0x251312a4 0x25130e4a 0x25143f43 0x25143ea2 0x25143d5b 0xff3b641 0xff3e202 0x7fce19f41609 0x7fce19e66133
2022.06.28 01:21:58.762976 [ 432 ] {} <Fatal> BaseDaemon: 0.1. inlined from ./build_docker/../src/Common/StackTrace.cpp:305: StackTrace::tryCapture()
2022.06.28 01:21:58.763001 [ 432 ] {} <Fatal> BaseDaemon: 0. ../src/Common/StackTrace.cpp:266: StackTrace::StackTrace() @ 0xfe89d43 in /workspace/clickhouse
2022.06.28 01:21:58.778914 [ 432 ] {} <Fatal> BaseDaemon: 1. ./build_docker/../src/Daemon/BaseDaemon.cpp:0: sanitizerDeathCallback() @ 0x100f9071 in /workspace/clickhouse
2022.06.28 01:21:59.720554 [ 432 ] {} <Fatal> BaseDaemon: 2. __sanitizer::Die() @ 0xfe3da06 in /workspace/clickhouse
2022.06.28 01:22:00.647518 [ 432 ] {} <Fatal> BaseDaemon: 3. ? @ 0xfe5260d in /workspace/clickhouse
2022.06.28 01:22:00.717521 [ 432 ] {} <Fatal> BaseDaemon: 4.1. inlined from ./build_docker/../src/Common/assert_cast.h:0: DB::ColumnVector<unsigned long> const& assert_cast<DB::ColumnVector<unsigned long> const&, DB::IColumn const&>(DB::IColumn const&)
2022.06.28 01:22:00.717569 [ 432 ] {} <Fatal> BaseDaemon: 4. ../src/Columns/ColumnVector.h:219: DB::ColumnVector<unsigned long>::compareAt(unsigned long, unsigned long, DB::IColumn const&, int) const @ 0x243c9aad in /workspace/clickhouse
2022.06.28 01:22:00.735708 [ 432 ] {} <Fatal> BaseDaemon: 5. ./build_docker/../src/Processors/Transforms/PartialSortingTransform.cpp:0: DB::(anonymous namespace)::compareWithThreshold(std::__1::vector<DB::IColumn const*, std::__1::allocator<DB::IColumn const*> > const&, unsigned long, std::__1::vector<COW<DB::IColumn>::immutable_ptr<DB::IColumn>, std::__1::allocator<COW<DB::IColumn>::immutable_ptr<DB::IColumn> > > const&, DB::SortDescription const&) @ 0x254f1db1 in /workspace/clickhouse
2022.06.28 01:22:00.751335 [ 432 ] {} <Fatal> BaseDaemon: 6. ./build_docker/../src/Processors/Transforms/PartialSortingTransform.cpp:156: DB::PartialSortingTransform::transform(DB::Chunk&) @ 0x254f0c8b in /workspace/clickhouse
2022.06.28 01:22:00.766954 [ 432 ] {} <Fatal> BaseDaemon: 7. ./build_docker/../src/Processors/ISimpleTransform.h:33: DB::ISimpleTransform::transform(DB::Chunk&, DB::Chunk&) @ 0x1d45a70b in /workspace/clickhouse
2022.06.28 01:22:00.778703 [ 432 ] {} <Fatal> BaseDaemon: 8. ./build_docker/../src/Processors/ISimpleTransform.cpp:99: DB::ISimpleTransform::work() @ 0x25118351 in /workspace/clickhouse
2022.06.28 01:22:00.785994 [ 432 ] {} <Fatal> BaseDaemon: 9. ./build_docker/../src/Processors/Executors/ExecutionThreadContext.cpp:50: DB::executeJob(DB::ExecutingGraph::Node*, DB::ReadProgressCallback*) @ 0x2513f740 in /workspace/clickhouse
2022.06.28 01:22:00.792709 [ 432 ] {} <Fatal> BaseDaemon: 10. ./build_docker/../src/Processors/Executors/ExecutionThreadContext.cpp:87: DB::ExecutionThreadContext::executeTask() @ 0x2513f317 in /workspace/clickhouse
2022.06.28 01:22:00.807473 [ 432 ] {} <Fatal> BaseDaemon: 11. ./build_docker/../src/Processors/Executors/PipelineExecutor.cpp:222: DB::PipelineExecutor::executeStepImpl(unsigned long, std::__1::atomic<bool>*) @ 0x251318f3 in /workspace/clickhouse
2022.06.28 01:22:00.820329 [ 432 ] {} <Fatal> BaseDaemon: 12. ./build_docker/../src/Processors/Executors/PipelineExecutor.cpp:333: DB::PipelineExecutor::executeImpl(unsigned long) @ 0x251312a4 in /workspace/clickhouse
2022.06.28 01:22:00.834712 [ 432 ] {} <Fatal> BaseDaemon: 13.1. inlined from ./build_docker/../contrib/libcxx/include/__memory/unique_ptr.h:284: std::__1::unique_ptr<DB::ExecutingGraph, std::__1::default_delete<DB::ExecutingGraph> >::operator->() const
2022.06.28 01:22:00.834740 [ 432 ] {} <Fatal> BaseDaemon: 13. ../src/Processors/Executors/PipelineExecutor.cpp:91: DB::PipelineExecutor::execute(unsigned long) @ 0x25130e4a in /workspace/clickhouse
2022.06.28 01:22:00.849309 [ 432 ] {} <Fatal> BaseDaemon: 14. ./build_docker/../src/Processors/Executors/PullingAsyncPipelineExecutor.cpp:0: DB::threadFunction(DB::PullingAsyncPipelineExecutor::Data&, std::__1::shared_ptr<DB::ThreadGroupStatus>, unsigned long) @ 0x25143f43 in /workspace/clickhouse
2022.06.28 01:22:00.863723 [ 432 ] {} <Fatal> BaseDaemon: 15. ./build_docker/../contrib/libcxx/include/type_traits:3648: decltype(static_cast<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&>(fp)()) std::__1::__invoke_constexpr<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&) @ 0x25143ea2 in /workspace/clickhouse
2022.06.28 01:22:00.878061 [ 432 ] {} <Fatal> BaseDaemon: 16.1. inlined from ./build_docker/../contrib/libcxx/include/tuple:0: operator()
2022.06.28 01:22:00.878089 [ 432 ] {} <Fatal> BaseDaemon: 16. ../contrib/libcxx/include/type_traits:3640: decltype(static_cast<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(fp)()) std::__1::__invoke<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'()&>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&) @ 0x25143d5b in /workspace/clickhouse
2022.06.28 01:22:00.887537 [ 432 ] {} <Fatal> BaseDaemon: 17.1. inlined from ./build_docker/../contrib/libcxx/include/__functional/function.h:1157: std::__1::function<void ()>::operator=(std::nullptr_t)
2022.06.28 01:22:00.887558 [ 432 ] {} <Fatal> BaseDaemon: 17. ../src/Common/ThreadPool.cpp:284: ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0xff3b641 in /workspace/clickhouse
2022.06.28 01:22:00.898664 [ 432 ] {} <Fatal> BaseDaemon: 18. ./build_docker/../src/Common/ThreadPool.cpp:0: 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>)::'lambda0'()> >(void*) @ 0xff3e202 in /workspace/clickhouse
2022.06.28 01:22:00.898687 [ 432 ] {} <Fatal> BaseDaemon: 19. ? @ 0x7fce19f41609 in ?
2022.06.28 01:22:00.898703 [ 432 ] {} <Fatal> BaseDaemon: 20. clone @ 0x7fce19e66133 in ?
2022.06.28 01:22:01.186369 [ 432 ] {} <Fatal> BaseDaemon: Integrity check of the executable skipped because the reference checksum could not be read. (calculated checksum: B5B8EF1A82E75D4E8745FC1D8B6E2736)

```

Probably related to #37992
if (description.size() == 1)
    {
        
        raw_block_columns[0]->compareColumn(*threshold_columns[0], 0, nullptr, compare_results,
                              description[0].direction, description[0].nulls_direction);
    }
    else
    {
        rows_to_compare.resize(num_rows);
        for (size_t i = 0; i < num_rows; ++i)
            rows_to_compare[i] = i;
        size_t size = description.size();
        for (size_t i = 0; i < size; ++i)
        {
            raw_block_columns[i]->compareColumn(*threshold_columns[i], 0, &rows_to_compare, compare_results,
                                  description[i].direction, description[i].nulls_direction);
            if (rows_to_compare.empty())
                break;
        }
    }
    size_t result_size_hint = 0;
    for (size_t i = 0; i < num_rows; ++i)
    {
        
        filter[i] = compare_results[i] < 0;
        result_size_hint += filter[i];
    }
    return result_size_hint;
}
bool compareWithThreshold(const ColumnRawPtrs & raw_block_columns, size_t min_block_index, const Columns & threshold_columns, const SortDescription & sort_description)