Skip to content

Bad alignment with empty tuples #84202

@PedroTadim

Description

@PedroTadim

Describe the bug

Easy to reproduce.

How to reproduce

Run Fiddle: https://fiddle.clickhouse.com/f2bbb34e-6899-430d-940f-676f963cd47f or in the client:

CREATE TABLE t0 (c0 Array(Tuple())) ENGINE = Memory;
SET max_insert_block_size = 4;
INSERT INTO TABLE t0 (c0) VALUES ([()]);
INSERT INTO TABLE t0 (c0) VALUES ([()]), ([()]), ([()]), ([()]), ([()]), ([()]), ([()]::Array(Tuple())), ([()]), ([(), ()]), ([()]); --Logical error

Error message and/or stacktrace

Stack trace:

Logical error: 'offsets_column has data inconsistent with nested_column. Data size: 1, last offset: 3'.                                                                      
Stack trace (when copying this message, always include the lines below):

0. contrib/llvm-project/libcxx/include/__exception/exception.h:113: Poco::Exception::Exception(String const&, int) @ 0x00000000265e58f2
1. src/Common/Exception.cpp:115: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000001407ab26
2. src/Common/Exception.h:119: DB::Exception::Exception(PreformattedMessage&&, int) @ 0x000000000cd9b5ac
3. src/Common/Exception.h:137: DB::Exception::Exception<unsigned long, unsigned long&>(int, FormatStringHelperImpl<std::type_identity<unsigned long>::type, std::type_identity<unsigned long&>::type>, unsigned long&&, unsigned long&) @ 0x0000000015b66836
4. src/Columns/ColumnArray.cpp:58: DB::ColumnArray::ColumnArray(COW<DB::IColumn>::mutable_ptr<DB::IColumn>&&, COW<DB::IColumn>::mutable_ptr<DB::IColumn>&&) @ 0x000000001d24db78
5. src/Common/COW.h:293: DB::ColumnArray::create(COW<DB::IColumn>::immutable_ptr<DB::IColumn> const&, COW<DB::IColumn>::immutable_ptr<DB::IColumn> const&) @ 0x000000000cdc4e50
6. src/Columns/ColumnArray.cpp:574: DB::ColumnArray::convertToFullColumnIfConst() const @ 0x000000001d251473
7. src/Formats/NativeWriter.cpp:74: DB::NativeWriter::writeData(DB::ISerialization const&, COW<DB::IColumn>::immutable_ptr<DB::IColumn> const&, DB::WriteBuffer&, std::optional<DB::FormatSettings> const&, unsigned long, unsigned long, unsigned long) @ 0x000000001e588183
8. src/Formats/NativeWriter.cpp:218: DB::NativeWriter::write(DB::Block const&) @ 0x000000001e588f5d
9. src/Client/Connection.cpp:1031: DB::Connection::sendData(DB::Block const&, String const&, bool) @ 0x000000001e3bef53
10. src/Client/ClientBase.cpp:2040: DB::ClientBase::sendDataFromPipe(DB::Pipe&&, std::shared_ptr<DB::IAST>, bool) @ 0x000000001e388a84
11. src/Client/ClientBase.cpp:1997: DB::ClientBase::sendDataFrom(DB::ReadBuffer&, DB::Block&, DB::ColumnsDescription const&, std::shared_ptr<DB::IAST>, bool) @ 0x000000001e3891ed
12. src/Client/ClientBase.cpp:1944: DB::ClientBase::sendData(DB::Block&, DB::ColumnsDescription const&, std::shared_ptr<DB::IAST>) @ 0x000000001e386632
13. src/Client/ClientBase.cpp:1793: DB::ClientBase::processInsertQuery(String, std::shared_ptr<DB::IAST>) @ 0x000000001e385ecb
14. src/Client/ClientBase.cpp:2280: DB::ClientBase::processParsedSingleQuery(std::basic_string_view<char, std::char_traits<char>>, std::shared_ptr<DB::IAST>, bool&, unsigned long) @ 0x000000001e37f38d
15. src/Client/ClientBase.cpp:2658: DB::ClientBase::executeMultiQuery(String const&) @ 0x000000001e38a751
16. src/Client/ClientBase.cpp:2898: DB::ClientBase::processQueryText(String const&) @ 0x000000001e38ba32
17. src/Client/ClientBase.cpp:3602: DB::ClientBase::runInteractive() @ 0x000000001e39428b
18. programs/client/Client.cpp:401: DB::Client::main(std::vector<String, std::allocator<String>> const&) @ 0x00000000142bd3b9
19. base/poco/Util/src/Application.cpp:315: Poco::Util::Application::run() @ 0x00000000266c06f1
20. programs/client/Client.cpp:1143: mainEntryClickHouseClient(int, char**) @ 0x00000000142c87c6
21. programs/main.cpp:340: main @ 0x000000000cd91fe7
22. strcmp @ 0x000000000002a578
23. __libc_start_main_alias_1 @ 0x000000000002a63b
24. _start @ 0x000000000cd8302e

Metadata

Metadata

Assignees

Labels

bugConfirmed user-visible misbehaviour in official releasefuzzProblem found by one of the fuzzers

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions