From 6cebd3ee1f6af71cd31da2489ecb369c7268c391 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 3 Apr 2021 16:03:37 +0300 Subject: [PATCH] Fix UB by unlocking the rwlock of the TinyLog from the same thread Before this patch the build with libstdc++ hangs for 00967_insert_into_distributed_different_types test (and I guess some others), this is because the rwlock is acquired from different thread as it was unlocked which causes UB [1], fix this by moving unlock into writeSuffix(). [1]: The pthread_rwlock_unlock() function shall release a lock held on the read-write lock object referenced by rwlock. Results are undefined if the read-write lock rwlock is not held by the **calling thread**. --- src/Storages/StorageTinyLog.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Storages/StorageTinyLog.cpp b/src/Storages/StorageTinyLog.cpp index 3cb4be50a8..6ce41dac61 100644 --- a/src/Storages/StorageTinyLog.cpp +++ b/src/Storages/StorageTinyLog.cpp @@ -357,6 +357,8 @@ void TinyLogBlockOutputStream::writeSuffix() for (const auto & file : column_files) storage.file_checker.update(file); storage.file_checker.save(); + + lock.unlock(); } -- GitLab