Repository navigation
ubsan/memsan fix. - #6937
ubsan/memsan fix.#6937
Conversation
|
This bug can be reproduced using the following query clickhouse build command is |
|
Actuall we can also make all StringRef zero value storages pointing to a global empty string. |
|
Great, thanks for investigating! Your test case reproduces the error for me, we probably should add it to the tests. It has a shorter form using the new Values table function: So, is the core cause that we compare uninitialized I think it would be good to achieve that the |
|
I guess it's because ZeroValueStorage is not initialized. https://github.com/yandex/ClickHouse/blob/master/dbms/src/Common/HashTable/HashTable.h#L223 |
|
Looking at emplaceIfZero, I don't see where the constructor is called for zero value Cell at all. Is this correct? Before, there was an explicit initialization of zero StringRef in GroupUniqArray: but I removed it in the key holder PR -- don't remember why. Anyway, it looks like it was a hack, and we should just properly call the constructor for zero Cell, the same way we do for all other Cells in emplaceNonZeroImpl. |
|
yeah, initializing it properly also fixes the bug. |
|
I'd prefer to call the Cell constructor in emplaceIfZero, because it would be only initialized on demand, and also would properly initialize complex cells like ClearableHashTableCell, which is not initialized to all zeros but has a version field. |
|
@akuzm you just caught me in the middle :) . That commit was supposed to run a CI test but I soon realize it's too slow so I did locally... |
|
I cannot reproduce the thread san build failure locally using Is it some flaky test? |
The logs are truncated, looks like some CI failure. |
There was a problem hiding this comment.
I think we should call the Cell constructor here, like we do for non-zero Cells. We already have Cells with non-trivial constructors, like ClearableHashTableCell.
There was a problem hiding this comment.
ClearableHashTableCell doesn't use zero storage
|
Ok, how can I trigger a retest without force push new stuff? |
|
The thread sanitizer CI failure looks unrelated. The performance test didn't finish, but it shouldn't be influenced because we didn't change much. Will merge as is. |
In hash tables, properly initialize zero key cell. (cherry picked from commit 75dc7d3)
In hash tables, properly initialize zero key cell. (cherry picked from commit 75dc7d3)
In hash tables, properly initialize zero key cell. (cherry picked from commit 75dc7d3)
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
When getting data from
ColumnArrayhttps://github.com/yandex/ClickHouse/blob/master/dbms/src/Columns/ColumnArray.cpp#L144we can get an invalid pointer when current array is empty. (due to left padding of podarray, it should be some global readonly address)
Theoretically we'd like to get the same pointer value in https://github.com/yandex/ClickHouse/blob/master/dbms/src/Columns/ColumnArray.cpp#L151 . However, since we have a dedicated ZeroValueStorage in hash table. The pointer of zero lengthed arrays becomes nil after placing into the agg states hash table, which leads to UBSan and MemSan failure.