Skip to content

Logical error: Reading from materialized CTE 'A' before it has been materialized (materialization was planned: B) (STID: 2467-2c2d) #100628

Closed

Description

@PedroTadim

Important: This issue was automatically generated and is used by CI for matching failures. DO NOT modify the body content. DO NOT remove labels.

Test name: Logical error: Reading from materialized CTE 'A' before it has been materialized (materialization was planned: B) (STID: 2467-2c2d)
CI report: AST fuzzer (arm_asan_ubsan)
Failing test history: cidb

Test output:

Error:
Logical error: 'Reading from materialized CTE 'y' before it has been materialized (materialization was planned: false)'.
---

Failed query:
WITH z AS (SELECT * FROM x WHERE (a * 3) >= materialize(255)), w AS MATERIALIZED (SELECT DISTINCT * FROM y WHERE (a < 1000) AND (333 <= a)), y AS MATERIALIZED (SELECT * FROM cte2__fuzz_2), x AS MATERIALIZED (SELECT * FROM cte1__fuzz_37 LIMIT 763) SELECT uniqHLL12(toNullable((SELECT '23:59:59' GROUP BY 1, 1)), a) FROM x WHERE (a IN (SELECT * FROM z)) AND (a <= (SELECT any(a) RESPECT NULLS FROM w)) LIMIT 164
---

Reproduce commands (auto-generated; may require manual adjustment):
CREATE TABLE cte1__fuzz_37 (`a` UInt32 NOT NULL) ENGINE = Memory;
CREATE TABLE cte1__fuzz_37 (`a` UInt32 NOT NULL) ENGINE = Memory;
INSERT INTO cte1__fuzz_37 SELECT * FROM numbers(10000);
CREATE TABLE cte2__fuzz_2 (`a` UInt16) ENGINE = Memory;
CREATE TABLE cte2__fuzz_2 (`a` UInt16) ENGINE = Memory;
INSERT INTO cte2__fuzz_2 SELECT * FROM numbers(5000);
WITH z AS (SELECT * FROM x WHERE (a * 3) >= materialize(255)), w AS MATERIALIZED (SELECT DISTINCT * FROM y WHERE (a < 1000) AND (333 <= a)), y AS MATERIALIZED (SELECT * FROM cte2__fuzz_2), x AS MATERIALIZED (SELECT * FROM cte1__fuzz_37 LIMIT 763) SELECT uniqHLL12(toNullable((SELECT '23:59:59' GROUP BY 1, 1)), a) FROM x WHERE (a IN (SELECT * FROM z)) AND (a <= (SELECT any(a) RESPECT NULLS FROM w)) LIMIT 164;
DROP TABLE IF EXISTS cte1__fuzz_37;
DROP TABLE IF EXISTS x;
DROP TABLE IF EXISTS z;
DROP TABLE IF EXISTS cte2__fuzz_2;
DROP TABLE IF EXISTS w;
DROP TABLE IF EXISTS y;
---

Stack trace:
__pthread_kill_implementation @ 0x0000000000082009
gsignal @ 0x000000000003a83c
__GI_abort @ 0x0000000000027134
src/Common/Exception.cpp:60:5: DB::abortOnFailedAssertion(String const&, std::basic_string_view<char, std::char_traits<char>>, void* const*, unsigned long, unsigned long) @ 0x0000000029108b40
src/Common/Exception.cpp:93:13: DB::handle_error_code(String const&, std::basic_string_view<char, std::char_traits<char>>, int, bool, std::vector<void*, std::allocator<void*>> const&) @ 0x000000002910ae10
src/Common/Exception.cpp:146:19: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000002910b37c
./src/Common/Exception.h:171:100: DB::Exception::Exception(String&&, int, String, bool) @ 0x0000000019c8ac28
./src/Common/Exception.h:57:54: DB::Exception::Exception(PreformattedMessage&&, int) @ 0x0000000019c89908
./src/Common/Exception.h:189:77: DB::Exception::Exception<String const&, bool>(int, FormatStringHelperImpl<std::type_identity<String const&>::type, std::type_identity<bool>::type>, String const&, bool&&) @ 0x000000004187eaac
src/Processors/QueryPlan/ReadFromMemoryStorageStep.cpp:64:23: DB::MemorySource::generate() @ 0x000000004187e43c
src/Processors/ISource.cpp:144:18: DB::ISource::tryGenerate() @ 0x0000000040a76a24
src/Processors/ISource.cpp:110:26: DB::ISource::work() @ 0x0000000040a7611c
src/Processors/Executors/ExecutionThreadContext.cpp:53: DB::executeJob(DB::ExecutingGraph::Node*, DB::ReadProgressCallback*)
src/Processors/Executors/ExecutionThreadContext.cpp:102:26: DB::ExecutionThreadContext::executeTask() @ 0x0000000040abc7d0
src/Processors/Executors/PipelineExecutor.cpp:351:26: DB::PipelineExecutor::executeStepImpl(unsigned long, DB::IAcquiredSlot*, std::atomic<bool>*) @ 0x0000000040a95e34
src/Processors/Executors/PipelineExecutor.cpp:279: DB::PipelineExecutor::executeSingleThread(unsigned long, DB::IAcquiredSlot*)
src/Processors/Executors/PipelineExecutor.cpp:602:5: DB::PipelineExecutor::executeImpl(unsigned long, bool) @ 0x0000000040a94474
src/Processors/Executors/PipelineExecutor.cpp:136:9: DB::PipelineExecutor::execute(unsigned long, bool) @ 0x0000000040a93a28
src/Processors/Executors/PullingAsyncPipelineExecutor.cpp:77: DB::threadFunction(DB::PullingAsyncPipelineExecutor::Data&, std::shared_ptr<DB::ThreadGroup>, unsigned long, bool)
src/Processors/Executors/PullingAsyncPipelineExecutor.cpp:103: operator()
inlined from ./contrib/llvm-project/libcxx/include/__type_traits/invoke.h:87: std::__invoke_result_impl<void, DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&>::type std::__invoke[abi:fe210105]<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&)
inlined from ./contrib/llvm-project/libcxx/include/tuple:1380: decltype(auto) std::__apply_tuple_impl[abi:fe210105]<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&, std::tuple<>&>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&, std::tuple<>&, std::__tuple_indices<...>)
inlined from ./contrib/llvm-project/libcxx/include/tuple:1384: decltype(auto) std::apply[abi:fe210105]<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&, std::tuple<>&>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&, std::tuple<>&)
inlined from ./src/Common/ThreadPool.h:312: operator()
inlined from ./contrib/llvm-project/libcxx/include/__type_traits/invoke.h:87: std::__invoke_result_impl<void, ThreadFromGlobalPoolImpl<true, true>::ThreadFromGlobalPoolImpl<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'()&>::type std::__invoke[abi:fe210105]<ThreadFromGlobalPoolImpl<true, true>::ThreadFromGlobalPoolImpl<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'()&>(ThreadFromGlobalPoolImpl<true, true>::ThreadFromGlobalPoolImpl<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'()&)
inlined from ./contrib/llvm-project/libcxx/include/__type_traits/invoke.h:342: void std::__invoke_void_return_wrapper<void, true>::__call[abi:fe210105]<ThreadFromGlobalPoolImpl<true, true>::ThreadFromGlobalPoolImpl<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'()&>(ThreadFromGlobalPoolImpl<true, true>::ThreadFromGlobalPoolImpl<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'()&)
inlined from ./contrib/llvm-project/libcxx/include/__type_traits/invoke.h:348: DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0 std::__invoke_r[abi:fe210105]<void, ThreadFromGlobalPoolImpl<true, true>::ThreadFromGlobalPoolImpl<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'()&>()
./contrib/llvm-project/libcxx/include/__functional/function.h:450:24: ? @ 0x0000000040ad2668
inlined from ./contrib/llvm-project/libcxx/include/__functional/function.h:508: ?
inlined from ./contrib/llvm-project/libcxx/include/__functional/function.h:772: ?
src/Common/ThreadPool.cpp:809:12: ThreadPoolImpl<std::thread>::ThreadFromThreadPool::worker() @ 0x000000002944ca48
inlined from ./contrib/llvm-project/libcxx/include/__type_traits/invoke.h:0: std::__invoke_result_impl<void, void (ThreadPoolImpl<std::thread>::ThreadFromThreadPool::*)(), ThreadPoolImpl<std::thread>::ThreadFromThreadPool*>::type std::__invoke[abi:fe210105]<void (ThreadPoolImpl<std::thread>::ThreadFromThreadPool::*)(), ThreadPoolImpl<std::thread>::ThreadFromThreadPool*>(void (ThreadPoolImpl<std::thread>::ThreadFromThreadPool::*&&)(), ThreadPoolImpl<std::thread>::ThreadFromThreadPool*&&)
inlined from ./contrib/llvm-project/libcxx/include/__thread/thread.h:159: void std::__thread_execute[abi:fe210105]<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void (ThreadPoolImpl<std::thread>::ThreadFromThreadPool::*)(), ThreadPoolImpl<std::thread>::ThreadFromThreadPool*, 2ul>(std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void (ThreadPoolImpl<std::thread>::ThreadFromThreadPool::*)(), ThreadPoolImpl<std::thread>::ThreadFromThreadPool*>&, std::__tuple_indices<2ul>)
./contrib/llvm-project/libcxx/include/__thread/thread.h:168: void* std::__thread_proxy[abi:fe210105]<std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void (ThreadPoolImpl<std::thread>::ThreadFromThreadPool::*)(), ThreadPoolImpl<std::thread>::ThreadFromThreadPool*>>(void*) @ 0x0000000029459c64
contrib/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239:28: asan_thread_start(void*) @ 0x0000000019c2e934
start_thread @ 0x0000000000080398
thread_start @ 0x00000000000e9e9c

Version info

Activity

  1. added
    testing
    fuzz
    on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fuzztesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions