https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=4d578ef2153133c8480489f2f88a3dc1ffddef85
commit 4d578ef2153133c8480489f2f88a3dc1ffddef85
Author: Paul Floyd <pj...@wa...>
Date: Fri Mar 14 21:56:35 2025 +0100
Bug 501479 - Illumos DRD pthread_mutex_init wrapper errors
Diff:
---
NEWS | 3 ++-
drd/drd_pthread_intercepts.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index e6a2855852..4d4c7eec46 100644
--- a/NEWS
+++ b/NEWS
@@ -59,7 +59,8 @@ are not entered into bugzilla tend to get forgotten about or ignored.
499212 mmap() with MAP_ALIGNED() returns unaligned pointer
501119 memcheck/tests/pointer-trace fails when run on NFS filesystem
501194 Fix ML_(check_macho_and_get_rw_loads) so that it is correct for any number of segment commands
-501348 glibc built with -march=x86-64-v3 does not work due to ld.so memcmp
+501348 glibc built with -march=x86-64-v3 does not work due to ld.so memcmp
+501479 Illumos DRD pthread_mutex_init wrapper errors
To see details of a given bug, visit
diff --git a/drd/drd_pthread_intercepts.c b/drd/drd_pthread_intercepts.c
index 7f20b0b4c2..bb92101931 100644
--- a/drd/drd_pthread_intercepts.c
+++ b/drd/drd_pthread_intercepts.c
@@ -876,6 +876,33 @@ PTH_FUNCS(int, pthreadZuonce, pthread_once_intercept,
(pthread_once_t *once_control, void (*init_routine)(void)),
(once_control, init_routine));
+#if defined(VGO_solaris)
+// see https://bugs.kde.org/show_bug.cgi?id=501479
+// temporary (?) workaround
+// Helgrind doesn't have this problem because it only redirects mutex_init
+// and not thread_mutex_init which also uses pthread_mutexattr_gettype
+// maybe DRD should do the same.
+typedef struct{
+ int pshared;
+ int protocol;
+ int prioceiling;
+ int type;
+ int robustness;
+} workaround_mattr_t;
+
+static int
+pthread_mutexattr_gettype_workaround(const pthread_mutexattr_t *attr, int *typep)
+{
+ workaround_mattr_t *ap;
+
+ if (attr == NULL || (ap = attr->__pthread_mutexattrp) == NULL ||
+ typep == NULL)
+ return (EINVAL);
+ *typep = ap->type;
+ return (0);
+}
+#endif
+
static __always_inline
int pthread_mutex_init_intercept(pthread_mutex_t *mutex,
const pthread_mutexattr_t* attr)
@@ -885,8 +912,13 @@ int pthread_mutex_init_intercept(pthread_mutex_t *mutex,
int mt;
VALGRIND_GET_ORIG_FN(fn);
mt = PTHREAD_MUTEX_DEFAULT;
+#if !defined(VGO_solaris)
if (attr)
pthread_mutexattr_gettype(attr, &mt);
+#else
+ if (attr)
+ pthread_mutexattr_gettype_workaround(attr, &mt);
+#endif
VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ_DRD_PRE_MUTEX_INIT,
mutex, DRD_(pthread_to_drd_mutex_type)(mt),
0, 0, 0);
|