Move check of MADV_DONTNEED into runtime (fixes clickhouse under qemu)#18169
Move check of MADV_DONTNEED into runtime (fixes clickhouse under qemu)#18169azat wants to merge 2 commits intoClickHouse:masterfrom
Conversation
be41611 to
9774c88
Compare
9774c88 to
8a7027d
Compare
alexey-milovidov
left a comment
There was a problem hiding this comment.
LGTM.
BTW, extern "C" in c source file looks pointless (as it cannot be included in cpp file).
Indeed, this is a copy-paste from glibc-compatibility.c, let's remove it |
There is no need in extern "C" when the is not processed as c++ module.
DetailsThe problem is that sanitizer is not "initialized" yet, and sanitizers traits ( |
|
Closed in favor of #18238 |
qemu does not support MADV_DONTNEED, and by not support it simply ignore it (i.e. return 0 -- no error). This issue has been "fixed" in ClickHouse#15590, however it just terminates the process, and completely breaks clickhouse under qemu (see also ClickHouse#15174). But there is no need in such strong protection, we can stop using madvise in jemalloc if MADV_DONTNEED does not work properly. And this is what ClickHouse#18169 was tried to do (by override madvise), however this will break sanitizers, at least TSAN and UBSAN. The problem there is that sanitizers initialization code uses madvise (and there is no way to turn this off with TSAN_OPTIONS) and overwritten madvise function will have sanitizers traits (__tsan_func_entry), while TSAN is not ready for this, and eventually it SIGSEGV. Interesting thing is that in the recent clang-12, madvise was replaced with direct syscall [1]. [1]: llvm/llvm-project@9f8c403 But it is better to make clickhouse compatible with clang < 12 too, so instead of override madvise completely, the runtime check was moved into the jemalloc code [2]. [2]: ClickHouse/jemalloc#1
Move check of MADV_DONTNEED (that is required by jemalloc) into runtime (fixes clickhouse under qemu)
Refs: #15174
Refs: #15590
Сс: @alexey-milovidov
Changelog category (leave one):
P.S. I've checked it manually