The __abort_fork_reset_child (introduced in
d40ac01cbbc66e6d9dbd8e3485605c63b2178251) call resets the lock after the
fork. This causes a DRD regression in valgrind
(https://bugs.kde.org/show_bug.cgi?id=503668), as it's effectively a
double initialization, despite it being actually ok in this case. As
suggested in https://sourceware.org/bugzilla/show_bug.cgi?id=32994#c2
we replace it here with a memcpy of another initialized lock instead,
which makes valgrind happy.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
#include <internal-signals.h>
#include <libc-lock.h>
#include <pthreadP.h>
+#include <string.h>
#include <unistd.h>
/* Try to get a machine dependent instruction which will make the
void
__abort_fork_reset_child (void)
{
- __libc_rwlock_init (lock);
+ /* Reinitialize lock without calling pthread_rwlock_init, to
+ avoid a valgrind DRD false positive. */
+ __libc_rwlock_define_initialized (, reset_lock);
+ memcpy (&lock, &reset_lock, sizeof (lock));
}
void