Commit Graph

48278 Commits

Author SHA1 Message Date
Azat Khuzhin
30f96dc525 Fix possible UAF from jobs in the ThreadPool on shutdown
ThreadPoolImpl<>::worker signaling that job is done while still storing
std::function<> object, and this can lead to problems on shutdown, since
in in this cast std::function<> can refers to some global/static object
that had been already destroyed (typical example is Logger).

I believe that this is exactly what TSAN reports about (decoded
manually, since llvm-symbolizer does not work in the test env):

<details>

```

- 2020-09-20 17:44:43   Write of size 8 at 0x7b1000008f78 by main thread (mutexes: write M1432):
    operator delete(void*, unsigned long)
    ??:0:0

    Poco::Logger::~Logger()
    /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Logger.cpp:39:1
    non-virtual thunk to Poco::Logger::~Logger()
    /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Logger.cpp:0:0

    Poco::RefCountedObject::release() const
    /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/include/Poco/RefCountedObject.h:82:24
    Poco::Logger::shutdown()
    /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Logger.cpp:346:16

    Poco::AutoLoggerShutdown::~AutoLoggerShutdown()
    /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Logger.cpp:459:4

    cxa_at_exit_wrapper(void*)
    ??:0:0

```

```
- 2020-09-20 17:44:43   Previous atomic read of size 4 at 0x7b1000008f78 by thread T116:

    __tsan_atomic32_load
    ??:0:0

    int std::__1::__cxx_atomic_load<int>(std::__1::__cxx_atomic_base_impl<int> const*, std::__1::memory_order)
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/atomic:970:12
    std::__1::__atomic_base<int, false>::load(std::__1::memory_order) const
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/atomic:1487:17
    std::__1::__atomic_base<int, false>::operator int() const
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/atomic:1491:53
    Poco::Logger::is(int) const
    /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/include/Poco/Logger.h:1264:9
    MemoryTracker::logPeakMemoryUsage() const
    /build/obj-x86_64-linux-gnu/../src/Common/MemoryTracker.cpp:59:5

    MemoryTracker::~MemoryTracker()
    /build/obj-x86_64-linux-gnu/../src/Common/MemoryTracker.cpp:46:13

    DB::ThreadGroupStatus::~ThreadGroupStatus()
    /build/obj-x86_64-linux-gnu/../src/Common/ThreadStatus.h:51:7
    std::__1::__shared_ptr_emplace<DB::ThreadGroupStatus, std::__1::allocator<DB::ThreadGroupStatus> >::__on_zero_shared()
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:3602:23

    std::__1::__shared_count::__release_shared()
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:3440:9
    std::__1::__shared_weak_count::__release_shared()
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:3482:27
    std::__1::shared_ptr<DB::ThreadGroupStatus>::~shared_ptr()
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:4207:19
    DB::PipelineExecutor::executeImpl(unsigned long)::$_4::~$_4()
    /build/obj-x86_64-linux-gnu/../src/Processors/Executors/PipelineExecutor.cpp:720:34
    ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PipelineExecutor::executeImpl(unsigned long)::$_4>(DB::PipelineExecutor::executeImpl(unsigned long)::$_4&&)::'lambda'()::~()
    /build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.h:161:54
    std::__1::__compressed_pair_elem<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PipelineExecutor::executeImpl(unsigned long)::$_4>(DB::PipelineExecutor::executeImpl(unsigned long)::$_4&&)::'lambda'(), 0, false>::~__compressed_pair_elem()
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:2188:8
    std::__1::__function::__alloc_func<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PipelineExecutor::executeImpl(unsigned long)::$_4>(DB::PipelineExecutor::executeImpl(unsigned long)::$_4&&)::'lambda'(), std::__1::allocator<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::Pip>
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:1559:38
    std::__1::__function::__func<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PipelineExecutor::executeImpl(unsigned long)::$_4>(DB::PipelineExecutor::executeImpl(unsigned long)::$_4&&)::'lambda'(), std::__1::allocator<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PipelineE>
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:1706:10

    std::__1::__function::__value_func<void ()>::~__value_func()
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:1828:19
    std::__1::function<void ()>::~function()
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2460:43
    ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>)
    /build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:268:5

    void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda1'()::operator()() const
    /build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:116:73
    decltype(std::__1::forward<void>(fp)(std::__1::forward<void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda1'()>(fp0)...)) std::__1::__invoke<void ThreadPoolImpl<std::__1::thread>::scheduleI>
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/type_traits:3519:1
    void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda1'(>
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/thread:273:5
    void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned lon>
    /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/thread:284:5

    __tsan_thread_start_func
    ??:0:0
```

```
- 2020-09-20 17:44:43   Mutex M1432 (0x0000181213a8) created at:
    pthread_mutex_init
    ??:0:0

    Poco::MutexImpl::MutexImpl()
    /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Mutex_POSIX.cpp:64:6

    Poco::Mutex::Mutex()
    /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Mutex.cpp:34:8

    __cxx_global_var_init
    /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Logger.cpp:28:15
    _GLOBAL__sub_I_Logger.cpp
    /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Logger.cpp:0:0

    __libc_csu_init
    ??:0:0
```

</details>
2020-09-20 23:46:28 +03:00
alexey-milovidov
e31a9c42e6
Merge pull request #14838 from BayoNet/docs/CLICKHOUSEDOCS-758-fixing-links
DOCS-758: Fixed links. Turned on the "links to nowhere" check for Russian language.
2020-09-20 23:08:55 +03:00
alexey-milovidov
21eeebeb7a
Merge pull request #14772 from otrazhenia/evgsudarikova-DOCSUP-2039
DOCS-323: LowCardinality
2020-09-20 23:07:43 +03:00
alexey-milovidov
07f95d0399
Update lowcardinality.md 2020-09-20 23:07:17 +03:00
alexey-milovidov
41a9264d27
Merge pull request #14866 from olgarev/revolg-DOCSUP-2033-Edit_and_translate_to_Russian
DOCSUP-2033: Edit and translate to Russian
2020-09-20 22:57:59 +03:00
alexey-milovidov
8630d1baf4
Merge pull request #15033 from amosbird/fixstringkey
Fix incorrect key condition of fixed strings.
2020-09-20 19:51:24 +03:00
alexey-milovidov
85483f8532
Merge pull request #14853 from ClickHouse/akz/optimized_index_binary_search
Optimized marks selection algorithm for continuous marks ranges
2020-09-20 19:48:45 +03:00
alexey-milovidov
e464f40733
Merge pull request #14884 from damozhaeva/dmozhaeva-DOCSUP-2041-edit-and-translate
DOCSUP-2041:  Edit and translate to Russian
2020-09-20 19:47:26 +03:00
alexey-milovidov
92756f4635
Update type-conversion-functions.md 2020-09-20 19:46:44 +03:00
alexey-milovidov
b2e9d0f20f
Update maxmap.md 2020-09-20 19:45:57 +03:00
alexey-milovidov
757be58fca
Update maxmap.md 2020-09-20 19:45:43 +03:00
alexey-milovidov
5244653493
Update maxmap.md 2020-09-20 19:45:27 +03:00
alexey-milovidov
f7cae4a57d
Merge pull request #14975 from ClickHouse/fix_merge_tree_settings_check
Fix check for merge tree settings sanity on server startup
2020-09-20 19:43:40 +03:00
alexey-milovidov
55eb533fda
Merge pull request #15034 from amosbird/fff
Improve performance of grouping by single LowCardinality(FixedString)
2020-09-20 19:42:38 +03:00
alexey-milovidov
a4337635cc
Update single_fixed_string_groupby.xml 2020-09-20 19:42:11 +03:00
alexey-milovidov
7b35a6a59a
Merge pull request #15028 from ClickHouse/fix-bar
Fix buffer overflow in "bar" function
2020-09-20 19:04:15 +03:00
alexey-milovidov
3f5d7843f6
Merge pull request #15029 from ClickHouse/cast-single-argument
Proper exception message for wrong number of arguments of CAST
2020-09-20 19:03:47 +03:00
alexey-milovidov
068e9f372e
Merge pull request #15030 from ClickHouse/base64-unpoison
Maybe fix MSan report in base64
2020-09-20 19:03:28 +03:00
alexey-milovidov
bf81dcbd2f
Merge pull request #15031 from den-crane/test/01475_mutation_with_if
more tests for mutation nullable
2020-09-20 19:02:51 +03:00
Vitaly Baranov
46ab2f76cd
Merge pull request #14919 from vitlibar/add-login-function-to-access-storage
Add login() function to IAccessStorage
2020-09-20 16:58:22 +03:00
alesapin
5ffee8808a
Alter remove column properties and TTLs (#14742) 2020-09-20 16:27:33 +03:00
Amos Bird
8ca4d6634e
better fixed string group by support 2020-09-20 15:20:09 +08:00
Amos Bird
fcee786320
Fix incorrect key condition of fixed strings. 2020-09-20 11:53:29 +08:00
alexey-milovidov
1474b80ecc
Merge pull request #15008 from ClickHouse/clang-tidy-11-without-enabling
Fix terribly wrong code
2020-09-20 02:00:54 +03:00
alexey-milovidov
636ffa8298
Merge pull request #15026 from ClickHouse/perf-test-tweaks
Remove obsolete code from performance test
2020-09-20 01:59:37 +03:00
Denis Zhuravlev
cd53a70163 constant output order 2020-09-19 18:40:14 -03:00
Denis Zhuravlev
71568130d8 more tests for #14646 2020-09-19 18:33:02 -03:00
Alexey Milovidov
0029c5512d Maybe fix MSan report in base64 2020-09-19 22:43:26 +03:00
Alexey Milovidov
5a47e64685 Proper exception message for wrong number of arguments of CAST 2020-09-19 22:34:24 +03:00
Alexey Milovidov
ace6130585 Added a test 2020-09-19 22:28:43 +03:00
Alexey Milovidov
dae3b40a55 Fix buffer overflow in "bar" function 2020-09-19 22:15:16 +03:00
alexey-milovidov
c185db46f9
Merge pull request #15023 from ClickHouse/remove-opencl
Remove OpenCL
2020-09-19 21:31:40 +03:00
alexey-milovidov
970fa25ba7
Merge pull request #15025 from ClickHouse/move-code-to-cpp
Move code to .cpp
2020-09-19 21:31:23 +03:00
alexey-milovidov
7ae4d01744
Update convertMySQLDataType.cpp 2020-09-19 19:31:08 +03:00
Alexey Milovidov
9fa49a6843 Fix clang-tidy 2020-09-19 19:29:15 +03:00
Alexey Milovidov
03aec83aec Remove obsolete code from performance test 2020-09-19 19:27:37 +03:00
Alexey Milovidov
c7a98132ac Slightly better code 2020-09-19 18:13:51 +03:00
Alexey Milovidov
b87ecc2ec1 Even more 2020-09-19 18:09:12 +03:00
Alexey Milovidov
c304032707 Even more 2020-09-19 18:02:11 +03:00
Alexey Milovidov
772eccf03d Move code to .cpp 2020-09-19 17:55:08 +03:00
Alexey Milovidov
059646743b Remove OpenCL 2020-09-19 17:20:00 +03:00
alexey-milovidov
8e2231036b
Merge pull request #14259 from olgarev/revolg-DOCSUP-1673-Doc_the_output_format_pretty_max_value_width_setting
DOCSUP-1673: Docs for the output_format_pretty_max_value_width setting.
2020-09-19 16:49:27 +03:00
alexey-milovidov
85506cee47
Merge pull request #14415 from dreamerfable/master
Update replacingmergetree.md
2020-09-19 16:42:30 +03:00
alexey-milovidov
2cab30ba8d
Merge pull request #14521 from hexiaoting/dev_like
Add new feature: SHOW DATABASES like 'xxx'
2020-09-19 16:34:37 +03:00
alexey-milovidov
079aa8aad7
Merge pull request #14625 from fanofxiaofeng/patch-1
"回话" -> "的会话"
2020-09-19 16:33:05 +03:00
alexey-milovidov
7bd357ec23
Merge pull request #14733 from ClickHouse/dependabot/pip/docs/tools/numpy-1.19.2
Bump numpy from 1.19.1 to 1.19.2 in /docs/tools
2020-09-19 16:27:35 +03:00
alexey-milovidov
acbdc51460
Merge pull request #14771 from amosbird/withsub
First attempt of supporting CTE
2020-09-19 16:25:34 +03:00
alexey-milovidov
45de465582
Merge pull request #15006 from azat/deb-build-python
Drop python from build dependencies (fixes building deb package on debian:testing)
2020-09-19 15:56:19 +03:00
alexey-milovidov
eb9ee723c3
Merge pull request #11913 from ClickHouse/compact-parts-by-default
Enable compact parts by default for small parts
2020-09-19 15:31:15 +03:00
Alexey Milovidov
2264622f69 Fix clang-tidy 2020-09-19 15:24:43 +03:00