https://clickhouse-test-reports.s3.yandex.net/25253/01eaaace8b61c15e5f1c3a5aca0f839aa3f97cfe/fuzzer_tsan/report.html#fail1

`SELECT row_number(NULL) OVER (PARTITION BY NULL ORDER BY 1048577 DESC NULLS LAST, '-9223372036854775807' DESC NULLS LAST, a ASC, NULL + '655.36' DESC NULLS FIRST, 2147483648 + 1025 DESC), a, 9223372036854775807 + 1, b, c FROM pk_order ORDER BY c DESC NULLS FIRST`

```
2021.06.14 04:12:43.930063 [ 50 ] {ca37d3b3-ef52-42c9-8512-45a4e4625237} <Debug> executeQuery: (from [::1]:46206, using production parser) SELECT row_number(NULL) OVER (PARTITION BY NULL ORDER BY 1048577 DESC NULLS LAST, '-9223372036854775807' DESC NULLS LAST, a ASC, NULL + '655.36' DESC NULLS FIRST, 2147483648 + 1025 DESC), a, 9223372036854775807 + 1, b, c FROM pk_order ORDER BY c DESC NULLS FIRST
2021.06.14 04:12:43.934986 [ 50 ] {ca37d3b3-ef52-42c9-8512-45a4e4625237} <Trace> ContextAccess (default): Access granted: SELECT(a, b, c) ON default.pk_order
2021.06.14 04:12:43.935455 [ 50 ] {ca37d3b3-ef52-42c9-8512-45a4e4625237} <Trace> InterpreterSelectQuery: FetchColumns -> Complete
2021.06.14 04:12:43.939678 [ 50 ] {ca37d3b3-ef52-42c9-8512-45a4e4625237} <Debug> default.pk_order (19c7157b-a83c-4a05-99c7-157ba83cba05) (SelectExecutor): Key condition: unknown
2021.06.14 04:12:43.940539 [ 50 ] {ca37d3b3-ef52-42c9-8512-45a4e4625237} <Debug> default.pk_order (19c7157b-a83c-4a05-99c7-157ba83cba05) (SelectExecutor): Selected 3/3 parts by partition key, 3 parts by primary key, 3/3 marks by primary key, 3 marks to read from 3 ranges
2021.06.14 04:12:43.941145 [ 50 ] {ca37d3b3-ef52-42c9-8512-45a4e4625237} <Debug> default.pk_order (19c7157b-a83c-4a05-99c7-157ba83cba05) (SelectExecutor): Reading approx. 11 rows with 3 streams
2021.06.14 04:12:43.952528 [ 45 ] {} <Trace> BaseDaemon: Received signal 11
2021.06.14 04:12:43.953529 [ 273 ] {} <Fatal> BaseDaemon: ########################################
2021.06.14 04:12:43.953833 [ 273 ] {} <Fatal> BaseDaemon: (version 21.7.1.7157, build id: 142C7324F20A327D7CA77F10AE65E4422EA439B4) (from thread 268) (query_id: ca37d3b3-ef52-42c9-8512-45a4e4625237) Received signal Segmentation fault (11)
2021.06.14 04:12:43.954028 [ 273 ] {} <Fatal> BaseDaemon: Address: NULL pointer. Access: read. Unknown si_code.
2021.06.14 04:12:43.954318 [ 273 ] {} <Fatal> BaseDaemon: Stack trace: 0x9233c17 0x13fe8550 0x13ed9d34 0x14a9f98f 0x14aa0444 0x14aa1339 0x14aa6cc3 0x148c3c05 0x148c1a92 0x148c4185 0x930a016 0x930d419 0x91d5d2d 0x7fccfe79a609 0x7fccfe6c1293
2021.06.14 04:12:52.534477 [ 273 ] {} <Fatal> BaseDaemon: 5. __tsan_read4 @ 0x9233c17 in /workspace/clickhouse
2021.06.14 04:12:53.646499 [ 273 ] {} <Fatal> BaseDaemon: 6.1. inlined from ./obj-x86_64-linux-gnu/../src/Columns/ColumnVector.h:40: DB::CompareHelper<unsigned int, unsigned int>::compare(unsigned int, unsigned int, int)
2021.06.14 04:12:53.646774 [ 273 ] {} <Fatal> BaseDaemon: 6. ../src/Columns/ColumnVector.h:206: DB::ColumnVector<unsigned int>::compareAt(unsigned long, unsigned long, DB::IColumn const&, int) const @ 0x13fe8550 in /workspace/clickhouse
2021.06.14 04:12:53.777172 [ 273 ] {} <Fatal> BaseDaemon: 7. ./obj-x86_64-linux-gnu/../src/Columns/ColumnConst.h:0: DB::ColumnConst::compareAt(unsigned long, unsigned long, DB::IColumn const&, int) const @ 0x13ed9d34 in /workspace/clickhouse
2021.06.14 04:12:54.245159 [ 273 ] {} <Fatal> BaseDaemon: 8.1. inlined from ./obj-x86_64-linux-gnu/../src/Processors/Transforms/WindowTransform.cpp:651: DB::WindowTransform::arePeers(DB::RowNumber const&, DB::RowNumber const&) const
2021.06.14 04:12:54.245383 [ 273 ] {} <Fatal> BaseDaemon: 8. ../src/Processors/Transforms/WindowTransform.cpp:704: DB::WindowTransform::advanceFrameEndCurrentRow() @ 0x14a9f98f in /workspace/clickhouse
2021.06.14 04:12:54.706828 [ 273 ] {} <Fatal> BaseDaemon: 9. ./obj-x86_64-linux-gnu/../src/Processors/Transforms/WindowTransform.cpp:807: DB::WindowTransform::advanceFrameEnd() @ 0x14aa0444 in /workspace/clickhouse
2021.06.14 04:12:55.167169 [ 273 ] {} <Fatal> BaseDaemon: 10. ./obj-x86_64-linux-gnu/../src/Processors/Transforms/WindowTransform.cpp:0: DB::WindowTransform::appendChunk(DB::Chunk&) @ 0x14aa1339 in /workspace/clickhouse
2021.06.14 04:12:55.699331 [ 273 ] {} <Fatal> BaseDaemon: 11. ./obj-x86_64-linux-gnu/../src/Processors/Transforms/WindowTransform.cpp:1321: DB::WindowTransform::work() @ 0x14aa6cc3 in /workspace/clickhouse
2021.06.14 04:12:56.339486 [ 273 ] {} <Fatal> BaseDaemon: 12.1. inlined from ./obj-x86_64-linux-gnu/../src/Processors/Executors/PipelineExecutor.cpp:100: operator()
2021.06.14 04:12:56.339827 [ 273 ] {} <Fatal> BaseDaemon: 12.2. inlined from ../contrib/libcxx/include/type_traits:3676: decltype(std::__1::forward<DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0&>(fp)()) std::__1::__invoke<DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0&>(DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0&)
2021.06.14 04:12:56.340083 [ 273 ] {} <Fatal> BaseDaemon: 12.3. inlined from ../contrib/libcxx/include/__functional_base:348: void std::__1::__invoke_void_return_wrapper<void>::__call<DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0&>(DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0&)
2021.06.14 04:12:56.340296 [ 273 ] {} <Fatal> BaseDaemon: 12.4. inlined from ../contrib/libcxx/include/functional:1608: std::__1::__function::__default_alloc_func<DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0, void ()>::operator()()
2021.06.14 04:12:56.340441 [ 273 ] {} <Fatal> BaseDaemon: 12. ../contrib/libcxx/include/functional:2089: void std::__1::__function::__policy_invoker<void ()>::__call_impl<std::__1::__function::__default_alloc_func<DB::PipelineExecutor::addJob(DB::ExecutingGraph::Node*)::$_0, void ()> >(std::__1::__function::__policy_storage const*) @ 0x148c3c05 in /workspace/clickhouse
2021.06.14 04:12:56.925804 [ 273 ] {} <Fatal> BaseDaemon: 13.1. inlined from ./obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:0: std::__1::__function::__policy_func<void ()>::operator()() const
2021.06.14 04:12:56.926071 [ 273 ] {} <Fatal> BaseDaemon: 13.2. inlined from ../contrib/libcxx/include/functional:2560: std::__1::function<void ()>::operator()() const
2021.06.14 04:12:56.926235 [ 273 ] {} <Fatal> BaseDaemon: 13. ../src/Processors/Executors/PipelineExecutor.cpp:586: DB::PipelineExecutor::executeStepImpl(unsigned long, unsigned long, std::__1::atomic<bool>*) @ 0x148c1a92 in /workspace/clickhouse
2021.06.14 04:12:57.563417 [ 273 ] {} <Fatal> BaseDaemon: 14.1. inlined from ./obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:2851: operator()
2021.06.14 04:12:57.563695 [ 273 ] {} <Fatal> BaseDaemon: 14.2. inlined from ../base/common/../ext/scope_guard.h:97: ext::basic_scope_guard<DB::PipelineExecutor::executeImpl(unsigned long)::$_4::operator()() const::'lambda'()>::invoke()
2021.06.14 04:12:57.563846 [ 273 ] {} <Fatal> BaseDaemon: 14.3. inlined from ../base/common/../ext/scope_guard.h:47: ~basic_scope_guard
2021.06.14 04:12:57.563992 [ 273 ] {} <Fatal> BaseDaemon: 14.4. inlined from ../src/Processors/Executors/PipelineExecutor.cpp:785: operator()
2021.06.14 04:12:57.564181 [ 273 ] {} <Fatal> BaseDaemon: 14.5. inlined from ../contrib/libcxx/include/type_traits:3682: decltype(std::__1::forward<DB::PipelineExecutor::executeImpl(unsigned long)::$_4&>(fp)()) std::__1::__invoke_constexpr<DB::PipelineExecutor::executeImpl(unsigned long)::$_4&>(DB::PipelineExecutor::executeImpl(unsigned long)::$_4&)
2021.06.14 04:12:57.564381 [ 273 ] {} <Fatal> BaseDaemon: 14.6. inlined from ../contrib/libcxx/include/tuple:1415: decltype(auto) std::__1::__apply_tuple_impl<DB::PipelineExecutor::executeImpl(unsigned long)::$_4&, std::__1::tuple<>&>(DB::PipelineExecutor::executeImpl(unsigned long)::$_4&, std::__1::tuple<>&, std::__1::__tuple_indices<>)
2021.06.14 04:12:57.564560 [ 273 ] {} <Fatal> BaseDaemon: 14.7. inlined from ../contrib/libcxx/include/tuple:1424: decltype(auto) std::__1::apply<DB::PipelineExecutor::executeImpl(unsigned long)::$_4&, std::__1::tuple<>&>(DB::PipelineExecutor::executeImpl(unsigned long)::$_4&, std::__1::tuple<>&)
2021.06.14 04:12:57.564707 [ 273 ] {} <Fatal> BaseDaemon: 14.8. inlined from ../src/Common/ThreadPool.h:182: operator()
2021.06.14 04:12:57.564937 [ 273 ] {} <Fatal> BaseDaemon: 14.9. inlined from ../contrib/libcxx/include/type_traits:3676: decltype(std::__1::forward<DB::PipelineExecutor::executeImpl(unsigned long)::$_4>(fp)()) std::__1::__invoke<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PipelineExecutor::executeImpl(unsigned long)::$_4>(DB::PipelineExecutor::executeImpl(unsigned long)::$_4&&)::'lambda'()&>(DB::PipelineExecutor::executeImpl(unsigned long)::$_4&&)
2021.06.14 04:12:57.565170 [ 273 ] {} <Fatal> BaseDaemon: 14.10. inlined from ../contrib/libcxx/include/__functional_base:348: void std::__1::__invoke_void_return_wrapper<void>::__call<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PipelineExecutor::executeImpl(unsigned long)::$_4>(DB::PipelineExecutor::executeImpl(unsigned long)::$_4&&)::'lambda'()&>(DB::PipelineExecutor::executeImpl(unsigned long)::$_4&&...)
2021.06.14 04:12:57.565381 [ 273 ] {} <Fatal> BaseDaemon: 14.11. inlined from ../contrib/libcxx/include/functional:1608: std::__1::__function::__default_alloc_func<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PipelineExecutor::executeImpl(unsigned long)::$_4>(DB::PipelineExecutor::executeImpl(unsigned long)::$_4&&)::'lambda'(), void ()>::operator()()
2021.06.14 04:12:57.565541 [ 273 ] {} <Fatal> BaseDaemon: 14. ../contrib/libcxx/include/functional:2089: void std::__1::__function::__policy_invoker<void ()>::__call_impl<std::__1::__function::__default_alloc_func<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PipelineExecutor::executeImpl(unsigned long)::$_4>(DB::PipelineExecutor::executeImpl(unsigned long)::$_4&&)::'lambda'(), void ()> >(std::__1::__function::__policy_storage const*) @ 0x148c4185 in /workspace/clickhouse
2021.06.14 04:12:57.684039 [ 273 ] {} <Fatal> BaseDaemon: 15.1. inlined from ./obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2210: std::__1::__function::__policy_func<void ()>::operator=(std::nullptr_t)
2021.06.14 04:12:57.684297 [ 273 ] {} <Fatal> BaseDaemon: 15.2. inlined from ../contrib/libcxx/include/functional:2533: std::__1::function<void ()>::operator=(std::nullptr_t)
2021.06.14 04:12:57.684457 [ 273 ] {} <Fatal> BaseDaemon: 15. ../src/Common/ThreadPool.cpp:269: ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0x930a016 in /workspace/clickhouse
2021.06.14 04:12:57.816551 [ 273 ] {} <Fatal> BaseDaemon: 16.1. inlined from ./obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:1655: std::__1::unique_ptr<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'()>, std::__1::default_delete<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'()> > >::reset(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'()>*)
2021.06.14 04:12:57.816808 [ 273 ] {} <Fatal> BaseDaemon: 16.2. inlined from ../contrib/libcxx/include/memory:1612: ~unique_ptr
2021.06.14 04:12:57.816981 [ 273 ] {} <Fatal> BaseDaemon: 16. ../contrib/libcxx/include/thread:293: 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*) @ 0x930d419 in /workspace/clickhouse
```

```
Changed settings: receive_timeout = '10', receive_data_timeout_ms = '10000', join_use_nulls = '1', optimize_read_in_order = '1', allow_experimental_window_functions = '1', max_distributed_depth = '0'
```
assert(end.block == partition_end.block + 1);
    
    const size_t n = partition_by_indices.size();
    if (n == 0)
    {
        
        
        partition_end = end;
        return;
    }
    
    
    
    
    
    
    
    const auto block_rows = blockRowsNumber(partition_end);
    for (; partition_end.row < block_rows; ++partition_end.row)
    {
        size_t i = 0;
        for (; i < n; i++)
        {
            const auto * ref = inputAt(current_row)[partition_by_indices[i]].get();
            const auto * c = inputAt(partition_end)[partition_by_indices[i]].get();
            if (c->compareAt(partition_end.row,
                    current_row.row, *ref,
                    1 ) != 0)