```
<Fatal> BaseDaemon: ########################################
<Fatal> BaseDaemon: (version 22.5.1.2079 (official build), build id: EBBF91C52186EE12) (from thread 46419) (query_id: 51268d18-4093-4de4-b3fa-18f3e7ff3ea9) (query: SELECT avgWeighted(x, y) FROM (SELECT NULL, 255 AS x, 1 AS y UNION ALL SELECT y, NULL AS x, 1 AS y);) Received signal Segmentation fault (11)
<Fatal> BaseDaemon: ########################################
<Fatal> BaseDaemon: Address: NULL pointer. Access: read. Unknown si_code.
<Fatal> BaseDaemon: Stack trace: 0xd99865d 0xd998c25 0x155c4d5f 0x155c43f5 0x16ebb800 0x16eb91f6 0x16d18ee8 0x16d0cbfe 0x16d0e4c4 0xb53fc47 0xb54367d 0x7fb28832e609 0x7fb288253163
<Fatal> BaseDaemon: 2. DB::AggregateFunctionNullVariadic<true, true, true>::add(char*, DB::IColumn const**, unsigned long, DB::Arena*) const @ 0xd99865d in /usr/bin/clickhouse
<Fatal> BaseDaemon: 3. DB::IAggregateFunctionHelper<DB::AggregateFunctionNullVariadic<true, true, true> >::addBatchSinglePlace(unsigned long, unsigned long, char*, DB::IColumn const**, DB::Arena*, long) const @ 0xd998c25 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 4. void DB::Aggregator::executeWithoutKeyImpl<false>(char*&, unsigned long, unsigned long, DB::Aggregator::AggregateFunctionInstruction*, DB::Arena*) const @ 0x155c4d5f in /usr/bin/clickhouse
<Fatal> BaseDaemon: 5. DB::Aggregator::executeOnBlock(std::__1::vector<COW<DB::IColumn>::immutable_ptr<DB::IColumn>, std::__1::allocator<COW<DB::IColumn>::immutable_ptr<DB::IColumn> > >, unsigned long, unsigned long, DB::AggregatedDataVariants&, std::__1::vector<DB::IColumn const*, std::__1::allocator<DB::IColumn const*> >&, std::__1::vector<std::__1::vector<DB::IColumn const*, std::__1::allocator<DB::IColumn const*> >, std::__1::allocator<std::__1::vector<DB::IColumn const*, std::__1::allocator<DB::IColumn const*> > > >&, bool&) const @ 0x155c43f5 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 6. DB::AggregatingTransform::consume(DB::Chunk) @ 0x16ebb800 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 7. DB::AggregatingTransform::work() @ 0x16eb91f6 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 8. DB::ExecutionThreadContext::executeTask() @ 0x16d18ee8 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 9. DB::PipelineExecutor::executeStepImpl(unsigned long, std::__1::atomic<bool>*) @ 0x16d0cbfe in /usr/bin/clickhouse
<Fatal> BaseDaemon: 10. ? @ 0x16d0e4c4 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 11. ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0xb53fc47 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 12. ? @ 0xb54367d in /usr/bin/clickhouse
<Fatal> BaseDaemon: (version 22.5.1.2079 (official build), build id: EBBF91C52186EE12) (from thread 43826) (query_id: 51268d18-4093-4de4-b3fa-18f3e7ff3ea9) (query: SELECT avgWeighted(x, y) FROM (SELECT NULL, 255 AS x, 1 AS y UNION ALL SELECT y, NULL AS x, 1 AS y);) Received signal Segmentation fault (11)
<Fatal> BaseDaemon: Address: NULL pointer. Access: read. Unknown si_code.
<Fatal> BaseDaemon: 13. ? @ 0x7fb28832e609 in ?
<Fatal> BaseDaemon: Stack trace: 0xd99865d 0xd998c25 0x155c4d5f 0x155c43f5 0x16ebb800 0x16eb91f6 0x16d18ee8 0x16d0cbfe 0x16d0e4c4 0xb53fc47 0xb54367d 0x7fb28832e609 0x7fb288253163
<Fatal> BaseDaemon: 14. clone @ 0x7fb288253163 in ?
<Fatal> BaseDaemon: 2. DB::AggregateFunctionNullVariadic<true, true, true>::add(char*, DB::IColumn const**, unsigned long, DB::Arena*) const @ 0xd99865d in /usr/bin/clickhouse
<Fatal> BaseDaemon: 3. DB::IAggregateFunctionHelper<DB::AggregateFunctionNullVariadic<true, true, true> >::addBatchSinglePlace(unsigned long, unsigned long, char*, DB::IColumn const**, DB::Arena*, long) const @ 0xd998c25 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 4. void DB::Aggregator::executeWithoutKeyImpl<false>(char*&, unsigned long, unsigned long, DB::Aggregator::AggregateFunctionInstruction*, DB::Arena*) const @ 0x155c4d5f in /usr/bin/clickhouse
<Fatal> BaseDaemon: 5. DB::Aggregator::executeOnBlock(std::__1::vector<COW<DB::IColumn>::immutable_ptr<DB::IColumn>, std::__1::allocator<COW<DB::IColumn>::immutable_ptr<DB::IColumn> > >, unsigned long, unsigned long, DB::AggregatedDataVariants&, std::__1::vector<DB::IColumn const*, std::__1::allocator<DB::IColumn const*> >&, std::__1::vector<std::__1::vector<DB::IColumn const*, std::__1::allocator<DB::IColumn const*> >, std::__1::allocator<std::__1::vector<DB::IColumn const*, std::__1::allocator<DB::IColumn const*> > > >&, bool&) const @ 0x155c43f5 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 6. DB::AggregatingTransform::consume(DB::Chunk) @ 0x16ebb800 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 7. DB::AggregatingTransform::work() @ 0x16eb91f6 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 8. DB::ExecutionThreadContext::executeTask() @ 0x16d18ee8 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 9. DB::PipelineExecutor::executeStepImpl(unsigned long, std::__1::atomic<bool>*) @ 0x16d0cbfe in /usr/bin/clickhouse
<Fatal> BaseDaemon: 10. ? @ 0x16d0e4c4 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 11. ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0xb53fc47 in /usr/bin/clickhouse
<Fatal> BaseDaemon: 12. ? @ 0xb54367d in /usr/bin/clickhouse
<Fatal> BaseDaemon: 13. ? @ 0x7fb28832e609 in ?
<Fatal> BaseDaemon: 14. clone @ 0x7fb288253163 in ?
<Fatal> BaseDaemon: Calculated checksum of the binary: 725445B106D580F2BC17459FE7679BDC. There is no information about the reference checksum.
<Fatal> BaseDaemon: Calculated checksum of the binary: 725445B106D580F2BC17459FE7679BDC. There is no information about the reference checksum.
<Fatal> Application: Child process was terminated by signal 11.
```

https://s3.amazonaws.com/clickhouse-test-reports/34775/a813f5996e95e424193265bb090ef7a402497d6e/stress_test__undefined__actions_.html
https://s3.amazonaws.com/clickhouse-test-reports/34775/a813f5996e95e424193265bb090ef7a402497d6e/stress_test__debug__actions_.html

Might be related to #35111 cc @azat 
else if (settings.offset)
            {
                ASTPtr new_limit_offset_ast = std::make_shared<ASTLiteral>(Field(static_cast<UInt64>(settings.offset)));
                select_query->setExpression(ASTSelectQuery::Expression::LIMIT_OFFSET, std::move(new_limit_offset_ast));
            }
            const ASTPtr limit_length_ast = select_query->limitLength();
            if (limit_length_ast)
            {
                limit_length = limit_length_ast->as<ASTLiteral &>().value.safeGet<UInt64>();
                UInt64 new_limit_length = 0;
                if (settings.offset == 0)
                    new_limit_length = std::min(limit_length, static_cast<UInt64>(settings.limit));
                else if (settings.offset < limit_length)
                    new_limit_length =  settings.limit ? std::min(static_cast<UInt64>(settings.limit), limit_length - settings.offset) : (limit_length - settings.offset);
                limit_length_ast->as<ASTLiteral &>().value = Field(new_limit_length);
            }
            else if (settings.limit)
            {
                ASTPtr new_limit_length_ast = std::make_shared<ASTLiteral>(Field(static_cast<UInt64>(settings.limit)));
                select_query->setExpression(ASTSelectQuery::Expression::LIMIT_LENGTH, std::move(new_limit_length_ast));
            }
            options.settings_limit_offset_done = true;
        }
    }
    for (size_t query_num = 0; query_num < num_children; ++query_num)
    {
        const Names & current_required_result_column_names
            = query_num == 0 ? required_result_column_names : required_result_column_names_for_other_selects[query_num];
        nested_interpreters.emplace_back(
            buildCurrentChildInterpreter(ast->list_of_selects->children.at(query_num), require_full_header ? Names() : current_required_result_column_names));