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
__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
accept4.c
atomic.h
clock_getres.c
clock_gettime.c
clock_nanosleep.c
COPYRIGHT
epoll.c
eventfd.c
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
lgammal.c
libm.h
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
musl_features.h
pipe2.c
posix_spawn.c
pow_data.c
pow_data.h
pow.c
powf_data.c
powf_data.h
powf.c
powl.c
pwritev.c
README
sched_cpucount.c
sched_getcpu.c
secure_getenv.c
strsignal.c
sync_file_range.c
syscall_ret.c
syscall.h
timerfd.c
timespec_get.c
utimensat.c
vasprintf.c
vdso.c

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.