Closed Anilm3 closed 3 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 67.64%. Comparing base (
98b1d15
) to head (73e5b44
).
LGTM! :shipit: How did you check if it does behave as intended?
Essentially validating that this works as expected, i.e. error == 0
. When using the old symbol, pthread_cond_init
results in errno being set to EINVAL (22)
.
pthread_condattr_init(&attr);
pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
error = pthread_cond_init(&cond_, &attr);
But this has also been indirectly validated through the PHP appsec CI and system tests, which were failing due to the remote configuration client failing to initialise, specifically due to boost io_context
not being able to initialise the condition variable.
pthread_cond_init
in glibc is provided in two different versions: the "current" version mapped to__pthread_cond_init
, and the legacy version mapped to__pthread_cond_init_2_0
. When using this function through a musl-built binary, the dynamic linker opts to resolve the non-default legacy version, presumably for backwards compatibility.However, the legacy API for condition variables forbids the use of clocks other than
CLOCK_REALTIME
, while in many casesCLOCK_MONOTONIC
is preferred instead, resulting in an unexpected failure to initialise a condition variable.The fix provided overrides
pthread_cond_init
with a weak symbol and then resolves the defaultpthread_cond_init
provided inlibc.so.6
. Note that this is only a problem inx86_64
.The images will be updated once this has been merged.
Related Jira:APPSEC-54528