src/uid_wrapper.c: force RTLD_NEXT for pthread_create/exit() if available
authorStefan Metzmacher <metze@samba.org>
Mon, 16 Jan 2023 14:20:00 +0000 (15:20 +0100)
committerAndreas Schneider <asn@samba.org>
Tue, 17 Jan 2023 13:26:38 +0000 (14:26 +0100)
This is needed as thread sanatizer also overloads pthread_create and
pthread_exit().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
src/uid_wrapper.c

index da5db9260fbe966eacca826725e539f8f89140e9..54bc15fe338fb0c8534f93fa622d0d3ce22754c3 100644 (file)
@@ -465,7 +465,16 @@ static void *uwrap_load_lib_handle(enum uwrap_lib lib)
        case UWRAP_LIBPTHREAD:
                handle = uwrap.libpthread.handle;
                if (handle == NULL) {
+#ifdef RTLD_NEXT
+                       /*
+                        * Because thread sanatizer also overloads
+                        * pthread_create() and pthread_exit() we need use
+                        * RTLD_NEXT instead of libpthread.so.0
+                        */
+                       handle = uwrap.libpthread.handle = RTLD_NEXT;
+#else
                        handle = dlopen("libpthread.so.0", flags);
+#endif
                        if (handle != NULL) {
                                break;
                        }