ClickHouse/base/glibc-compatibility/musl
Azat Khuzhin a4f9e1da5b Fix getauxval() by using procfs with fallback to environ
getauxval() from glibc-compatibility did not work always correctly:

- It does not work after setenv(), and this breaks vsyscalls,
  like sched_getcpu() [1] (and BaseDaemon.cpp always set TZ if timezone
  is defined, which is true for CI [2]).

  Also note, that fixing setenv() will not fix LSan,
  since the culprit is getauxval()

  [1]: https://bugzilla.redhat.com/show_bug.cgi?id=1163404
  [2]: ClickHouse#32928 (comment)

- Another think that is definitely broken is LSan (Leak Sanitizer), it
  relies on worked getauxval() but it does not work if __environ is not
  initialized yet (there is even a commit about this).

  And because of, at least, one leak had been introduced [3]:

    [3]: ClickHouse#33840

Fix this by using /proc/self/auxv with fallback to environ solution to
make it compatible with environment that does not allow reading from
auxv (or no procfs).

v2: add fallback to environ solution
v3: fix return value for __auxv_init_procfs()
(cherry picked from commit f187c3499a)
v4: more verbose message on errors, CI founds [1]:
    AUXV already has value (529267711)
    [1]: https://s3.amazonaws.com/clickhouse-test-reports/39103/2325f7e8442d1672ce5fb43b11039b6a8937e298/stress_test__memory__actions_.html
v5: break at AT_NULL
v6: ignore AT_IGNORE
v7: suppress TSan and remove superior check to avoid abort() in case of race
v8: proper suppressions (not inner function but itself)
Refs: #33957
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-07-25 01:22:04 +03:00
..
aarch64
x86_64 Implemented unwind info for __syscall function 2020-03-03 05:29:51 +03:00
__math_divzero.c
__math_divzerof.c
__math_invalid.c
__math_invalidf.c
__math_oflow.c
__math_oflowf.c
__math_uflow.c
__math_uflowf.c
__math_xflow.c
__math_xflowf.c
__polevll.c Add powf and powl to glibc-compatibility 2020-12-21 02:54:05 +03:00
accept4.c glibc-compatibility: Add accept4() from musl 1.2.1. 2020-11-24 17:55:02 +03:00
atomic.h
clock_getres.c Fix glibc compatibility 2020-03-23 19:51:06 +03:00
clock_gettime.c
clock_nanosleep.c
COPYRIGHT
epoll.c glibc-compatibility: Add epoll_create1() from musl 1.2.1. 2020-11-24 17:55:02 +03:00
eventfd.c glibc-compatibility: Add eventfd(), eventfd_read(), eventfd_write() from musl 1.2.1. 2020-11-24 17:55:02 +03:00
exp2.c
exp2f_data.c
exp2f_data.h
exp2f.c
exp_data.c
exp_data.h
exp.c
fallocate.c
fcntl.c
futimens.c
getauxval.c Fix getauxval() by using procfs with fallback to environ 2022-07-25 01:22:04 +03:00
getentropy.c
getrandom.c
glob.c
lgamma.c Fix warnings by PVS-Studio in some third-party code 2021-05-08 22:41:06 +03:00
lgammal.c Fix warnings by PVS-Studio in some third-party code 2021-05-08 22:41:06 +03:00
libm.h Fix warnings by PVS-Studio 2021-05-08 23:57:08 +03:00
log2_data.c
log2_data.h
log2.c
log2f_data.c
log2f_data.h
log2f.c
log_data.c
log_data.h
log.c
logf_data.c
logf_data.h
logf.c
mkstemps.c add .sql suffix 2020-12-21 14:43:06 +08:00
musl_features.h
pipe2.c
posix_spawn.c
pow_data.c
pow_data.h
pow.c
powf_data.c Add powf and powl to glibc-compatibility 2020-12-21 02:54:05 +03:00
powf_data.h Add powf and powl to glibc-compatibility 2020-12-21 02:54:05 +03:00
powf.c Fix warnings by PVS-Studio in some third-party code 2021-05-08 22:41:06 +03:00
powl.c Fix codespell warnings. Split style checks. Update style checks docker 2020-12-24 13:17:52 +03:00
pwritev.c
README
sched_cpucount.c
sched_getcpu.c Fix msan warnings 2021-01-29 19:11:50 +03:00
secure_getenv.c glibc-compatibility: Add secure_getenv(). 2020-11-24 17:55:02 +03:00
strsignal.c Import strsignal from Musl 2021-01-08 08:09:30 +03:00
sync_file_range.c add sync_file_range for glibc-compatibility 2020-11-11 09:08:52 +08:00
syscall_ret.c
syscall.h glibc-compatibility: Add accept4() from musl 1.2.1. 2020-11-24 17:55:02 +03:00
timerfd.c Add timerfd from musl 2020-12-14 17:41:59 +03:00
timespec_get.c
utimensat.c
vasprintf.c
vdso.c glibc-compatibility: Add getauxval(). 2020-11-24 17:55:02 +03:00

Tiny pieces extracted from MUSL library.

git://git.musl-libc.org/musl
c10bc61508dc52b8315084e628f36a6c3c2dabb1

NOTE: Files was edited.

NOTE: Math related files are pulled from commit 6ad514e4e278f0c3b18eb2db1d45638c9af1c07f.