The newly added t-lock-single-thread test works fine on x86_64/glibc, but fails on x86_64/musl:
libgpg-error-1.43/tests # ./t-lock-single-posix --verbose --debug t-lock-single: syscall pre called t-lock-single: syscall post called t-lock-single: Single thread situation is not correctly handled t-lock-single: syscall pre called t-lock-single: syscall post called
With the following changes to the test:
--- t-lock-single-posix.c.orig 2021-11-19 12:59:08.731296130 +0000 +++ t-lock-single-posix.c 2021-11-19 13:00:52.636530421 +0000 @@ -34,7 +34,7 @@ GPGRT_LOCK_DEFINE (the_lock); -static int locking_used; +static int locking_used = 0; #ifdef USE_POSIX_THREADS_FROM_LIBC #include <pthread.h> @@ -52,6 +52,7 @@ { gpg_err_code_t rc; + show("run_test start\n"); rc = gpgrt_lock_lock (&the_lock); if (rc) fail ("gpgrt_lock_lock failed at %d: %s", __LINE__, gpg_strerror (rc)); @@ -60,6 +61,8 @@ if (rc) fail ("gpgrt_lock_unlock failed at %d: %s", __LINE__,gpg_strerror (rc)); + show ("locking_used after lock/unlock: %d\n", locking_used); + if (locking_used) /*It was incremented, even with single thread. */ fail ("Single thread situation is not correctly handled\n"); @@ -91,6 +94,8 @@ fail ("Multiple threads situation is not correctly handled\n"); } #endif + + show("run_test end\n"); } @@ -100,6 +105,8 @@ if (debug) show ("syscall pre called\n"); locking_used++; + + show ("locking used: %d\n", locking_used); } static void
I get this debug output:
libgpg-error-1.43/tests # ./t-lock-single-posix --verbose --debug t-lock-single: run_test start t-lock-single: syscall pre called t-lock-single: locking used: 1 t-lock-single: syscall post called t-lock-single: locking_used after lock/unlock: 1 t-lock-single: Single thread situation is not correctly handled t-lock-single: run_test end t-lock-single: syscall pre called t-lock-single: locking used: 2 t-lock-single: syscall post called
For comparison, on x86_64/glibc I get this output with the same changes applied:
libgpg-error-1.43/tests # ./t-lock-single-posix --verbose --debug t-lock-single: run_test start t-lock-single: locking_used after lock/unlock: 0 t-lock-single: syscall pre called t-lock-single: locking used: 1 t-lock-single: syscall post called t-lock-single: run_test end t-lock-single: syscall pre called t-lock-single: locking used: 2 t-lock-single: syscall post called
Any idea what's going on here?