]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 501479 - Illumos DRD pthread_mutex_init wrapper errors
authorPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 14 Mar 2025 20:56:35 +0000 (21:56 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 14 Mar 2025 20:56:35 +0000 (21:56 +0100)
NEWS
drd/drd_pthread_intercepts.c

diff --git a/NEWS b/NEWS
index e6a285585201155c1a75c81f08059fd140b20d0c..4d4c7eec4686b51e7ccd7f760ddd9bd7dffd396b 100644 (file)
--- 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
index 7f20b0b4c21414766b76b3763a03308e15b2f58b..bb921019319b6f8810b25485acb6224562e9006c 100644 (file)
@@ -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);