Skip to content

Crash in window function with LowCardinality datatype #31114

@UnamedRus

Description

@UnamedRus

Describe what's wrong

ClickHouse crashes if you execute max(id) OVER (PARTITION BY id) over LowCardinality column

Does it reproduce on recent release?

Yes.
ClickHouse version 21.11

How to reproduce

SELECT max(id) OVER (PARTITION BY id) AS id
FROM
(
    SELECT materialize('aaaa') AS id
    FROM numbers_mt(1000000)
)
FORMAT `Null`

Ok.

0 rows in set. Elapsed: 0.144 sec. Processed 1.00 million rows, 8.00 MB (6.95 million rows/s., 55.58 MB/s.)

SELECT max(id) OVER (PARTITION BY id) AS aid
FROM
(
    SELECT materialize(toLowCardinality('aaaa')) AS id
    FROM numbers_mt(1000000)
)
FORMAT `Null`

[ 14776 ] <Fatal> BaseDaemon: ########################################
[ 14776 ] <Fatal> BaseDaemon: (version 21.11.1.8526, build id: 33B572DD4B9C2BE5F65F58755B19729DE40A4869) (from thread 14740) (query_id: d5299144-24c8-4d91-a122-09065f33bbaa) Received signal Segmentation fault (11)
[ 14776 ] <Fatal> BaseDaemon: Address: 0x1 Access: read. Address not mapped to object.
[ 14776 ] <Fatal> BaseDaemon: Stack trace: 0x9b389b0 0x1323afd3 0x1323b45e 0x1324051f 0x13070e9b 0x1306ce51 0x13072e25 0x9b80c57 0x9b8465d 0x7f1fe3050609 0x7f1fe2f4a293
[ 14776 ] <Fatal> BaseDaemon: 2. memcpy @ 0x9b389b0 in /usr/bin/clickhouse
[ 14776 ] <Fatal> BaseDaemon: 3. DB::WindowTransform::updateAggregationState() @ 0x1323afd3 in /usr/bin/clickhouse
[ 14776 ] <Fatal> BaseDaemon: 4. DB::WindowTransform::appendChunk(DB::Chunk&) @ 0x1323b45e in /usr/bin/clickhouse
[ 14776 ] <Fatal> BaseDaemon: 5. DB::WindowTransform::work() @ 0x1324051f in /usr/bin/clickhouse
[ 14776 ] <Fatal> BaseDaemon: 6. ? @ 0x13070e9b in /usr/bin/clickhouse
[ 14776 ] <Fatal> BaseDaemon: 7. DB::PipelineExecutor::executeStepImpl(unsigned long, unsigned long, std::__1::atomic<bool>*) @ 0x1306ce51 in /usr/bin/clickhouse
[ 14776 ] <Fatal> BaseDaemon: 8. ? @ 0x13072e25 in /usr/bin/clickhouse
[ 14776 ] <Fatal> BaseDaemon: 9. ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0x9b80c57 in /usr/bin/clickhouse
[ 14776 ] <Fatal> BaseDaemon: 10. ? @ 0x9b8465d in /usr/bin/clickhouse
[ 14776 ] <Fatal> BaseDaemon: 11. start_thread @ 0x9609 in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
[ 14776 ] <Fatal> BaseDaemon: 12. clone @ 0x122293 in /usr/lib/x86_64-linux-gnu/libc-2.31.so
[ 14776 ] <Fatal> BaseDaemon: Calculated checksum of the binary: 8E1781B29E0174AC66B92E409A0E916E. There is no information about the reference checksum.

Expected behavior

Both queries works

Metadata

Metadata

Labels

bugConfirmed user-visible misbehaviour in official releasecomp-datatype-wrapperType modifiers/wrappers (Nullable, LowCardinality, etc.).comp-window-functionsWindow function execution + frame handling (ROW_NUMBER/RANK/LAG/LEAD, frames, partitions, order).crashCrash / segfault / abortmajor

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions