From 35fab451d9ec11a7e02df750fb24feb21e9732b8 Mon Sep 17 00:00:00 2001 From: Vladimir Mezentsev Date: Sun, 16 Apr 2023 13:55:48 -0700 Subject: [PATCH] gprofng: 30360 Seg. Fault when application uses std::thread We interpose a lot of libC functions (dlopen, fork, pthread_create, etc.). Some of these functions have versions. For example, % nm -D /lib64/gprofng/libgp-collector.so | grep thread_create@ | sort 000000000004b420 T pthread_create@GLIBC_2.34 000000000004b490 T pthread_create@GLIBC_2.17 000000000004b500 T pthread_create@GLIBC_2.2.5 000000000004b570 T pthread_create@GLIBC_2.1 000000000004b5e0 T pthread_create@GLIBC_2.0 Our library does not set the default version for symbols. This is correct because we don't know which libC will be used. gcc and g++ links differently the version symbols when the default version is not set. c-linker is using our pthread_create@GLIBC_2.34 and c++-linker is using our pthread_create@GLIBC_2.0 by default. The current implementation of the interposed functions is: If we are in our pthread_create@GLIBC_, we use dlvsym (dlflag, "pthread_create", "GLIBC_") to find and call the same function from libC. In the test from PR 30360, pthread_create@GLIBC_2.0 is not in the current libC. We need to call the default version symbol from libC. gprofng/ChangeLog 2023-04-16 Vladimir Mezentsev PR gprofng/30360 * libcollector/iotrace.c: Find and call a default libC version symbol. * libcollector/dispatcher.c: Likewise. * libcollector/iotrace.c: Likewise. * libcollector/linetrace.c: Likewise. * libcollector/mmaptrace.c: Likewise. * libcollector/synctrace.c: Likewise. * libcollector/collector.h (REAL_DCL): Remove an unused argument. --- gprofng/libcollector/collector.h | 2 +- gprofng/libcollector/dispatcher.c | 35 ++++++++----- gprofng/libcollector/iotrace.c | 87 ++++++++++++++++++------------- gprofng/libcollector/linetrace.c | 50 ++++++++++++------ gprofng/libcollector/mmaptrace.c | 16 +++--- gprofng/libcollector/synctrace.c | 40 +++++++------- 6 files changed, 136 insertions(+), 94 deletions(-) diff --git a/gprofng/libcollector/collector.h b/gprofng/libcollector/collector.h index 12a6e15a733..4de7022be11 100644 --- a/gprofng/libcollector/collector.h +++ b/gprofng/libcollector/collector.h @@ -50,7 +50,7 @@ #else #define DCL_FUNC_VER(REAL_DCL, sym, ver) \ SYMVER_ATTRIBUTE (__collector_ ## sym, ver) \ - REAL_DCL (__collector_ ## sym, CALL_REAL (sym)) + REAL_DCL (__collector_ ## sym) #endif extern hrtime_t __collector_start_time; diff --git a/gprofng/libcollector/dispatcher.c b/gprofng/libcollector/dispatcher.c index 82c4bb7a533..9bb694cabd7 100644 --- a/gprofng/libcollector/dispatcher.c +++ b/gprofng/libcollector/dispatcher.c @@ -695,7 +695,16 @@ init_interposition_intf () __real_pthread_sigmask_2_17 = dlvsym (dlflag, "pthread_sigmask", "GLIBC_2.17"); __real_pthread_sigmask_2_2_5 = dlvsym (dlflag, "pthread_sigmask", "GLIBC_2.2.5"); __real_pthread_sigmask_2_0 = dlvsym (dlflag, "pthread_sigmask", "GLIBC_2.0"); - __real_pthread_sigmask = dlsym (dlflag, "pthread_sigmask"); + if (__real_pthread_sigmask_2_32) + __real_pthread_sigmask = __real_pthread_sigmask_2_32; + else if (__real_pthread_sigmask_2_17) + __real_pthread_sigmask = __real_pthread_sigmask_2_17; + else if (__real_pthread_sigmask_2_2_5) + __real_pthread_sigmask = __real_pthread_sigmask_2_2_5; + else if (__real_pthread_sigmask_2_0) + __real_pthread_sigmask = __real_pthread_sigmask_2_0; + else + __real_pthread_sigmask = dlsym (dlflag, "pthread_sigmask"); __real_pthread_create_2_34 = dlvsym (dlflag, "pthread_create", "GLIBC_2.34"); __real_pthread_create_2_17 = dlvsym (dlflag, "pthread_create", "GLIBC_2.17"); @@ -922,12 +931,12 @@ gprofng_timer_create (int (real_func) (), clockid_t clockid, return -1; } -#define DCL_TIMER_CREATE(dcl_f, real_f) \ +#define DCL_TIMER_CREATE(dcl_f) \ int dcl_f (clockid_t clockid, struct sigevent *sevp, timer_t *timerid) \ { \ - if ((real_f) == NULL) \ + if (__real_timer_create == NULL) \ init_interposition_intf (); \ - return gprofng_timer_create (real_f, clockid, sevp, timerid); \ + return gprofng_timer_create (__real_timer_create, clockid, sevp, timerid); \ } DCL_FUNC_VER (DCL_TIMER_CREATE, timer_create_2_34, timer_create@GLIBC_2.34) @@ -935,7 +944,7 @@ DCL_FUNC_VER (DCL_TIMER_CREATE, timer_create_2_17, timer_create@GLIBC_2.17) DCL_FUNC_VER (DCL_TIMER_CREATE, timer_create_2_3_3, timer_create@GLIBC_2.3.3) DCL_FUNC_VER (DCL_TIMER_CREATE, timer_create_2_2_5, timer_create@GLIBC_2.2.5) DCL_FUNC_VER (DCL_TIMER_CREATE, timer_create_2_2, timer_create@GLIBC_2.2) -DCL_TIMER_CREATE (timer_create, CALL_REAL (timer_create)) +DCL_TIMER_CREATE (timer_create) /*------------------------------------------------------------- setitimer */ int @@ -1055,19 +1064,19 @@ gprofng_pthread_sigmask (int (real_func) (), } -#define DCL_PTHREAD_SIGMASK(dcl_f, real_f) \ +#define DCL_PTHREAD_SIGMASK(dcl_f) \ int dcl_f (int how, const sigset_t *iset, sigset_t* oset) \ { \ - if ((real_f) == NULL) \ + if (__real_pthread_sigmask == NULL) \ init_interposition_intf (); \ - return gprofng_pthread_sigmask (real_f, how, iset, oset); \ + return gprofng_pthread_sigmask (__real_pthread_sigmask, how, iset, oset); \ } DCL_FUNC_VER (DCL_PTHREAD_SIGMASK, pthread_sigmask_2_32, pthread_sigmask@GLIBC_2.32) DCL_FUNC_VER (DCL_PTHREAD_SIGMASK, pthread_sigmask_2_17, pthread_sigmask@GLIBC_2.17) DCL_FUNC_VER (DCL_PTHREAD_SIGMASK, pthread_sigmask_2_2_5, pthread_sigmask@GLIBC_2.2.5) DCL_FUNC_VER (DCL_PTHREAD_SIGMASK, pthread_sigmask_2_0, pthread_sigmask@GLIBC_2.0) -DCL_PTHREAD_SIGMASK (pthread_sigmask, CALL_REAL(pthread_sigmask)) +DCL_PTHREAD_SIGMASK (pthread_sigmask) /*----------------------------------------------------------- pthread_create */ typedef struct _CollectorArgs @@ -1154,13 +1163,13 @@ gprofng_pthread_create (int (real_func) (), pthread_t *thread, } -#define DCL_PTHREAD_CREATE(dcl_f, real_f) \ +#define DCL_PTHREAD_CREATE(dcl_f) \ int dcl_f (pthread_t *thread, const pthread_attr_t *attr, \ void *(*func)(void*), void *arg) \ { \ - if ((real_f) == NULL) \ + if (__real_pthread_create == NULL) \ init_interposition_intf (); \ - return gprofng_pthread_create (real_f, thread, attr, func, arg); \ + return gprofng_pthread_create (__real_pthread_create, thread, attr, func, arg); \ } DCL_FUNC_VER (DCL_PTHREAD_CREATE, pthread_create_2_34, pthread_create@GLIBC_2.34) @@ -1168,7 +1177,7 @@ DCL_FUNC_VER (DCL_PTHREAD_CREATE, pthread_create_2_17, pthread_create@GLIBC_2.17 DCL_FUNC_VER (DCL_PTHREAD_CREATE, pthread_create_2_2_5, pthread_create@GLIBC_2.2.5) DCL_FUNC_VER (DCL_PTHREAD_CREATE, pthread_create_2_1, pthread_create@GLIBC_2.1) DCL_FUNC_VER (DCL_PTHREAD_CREATE, pthread_create_2_0, pthread_create@GLIBC_2.0) -DCL_PTHREAD_CREATE (pthread_create, CALL_REAL (pthread_create)) +DCL_PTHREAD_CREATE (pthread_create) int __collector_ext_clone_pthread (int (*fn)(void *), void *child_stack, int flags, void *arg, diff --git a/gprofng/libcollector/iotrace.c b/gprofng/libcollector/iotrace.c index d27f8524d7d..c0ea7497b09 100644 --- a/gprofng/libcollector/iotrace.c +++ b/gprofng/libcollector/iotrace.c @@ -450,6 +450,21 @@ init_io_intf () else __real_fgetpos64 = dlsym (dlflag, "fgetpos64"); + __real_fsetpos64_2_17 = dlvsym (dlflag, "fsetpos64", "GLIBC_2.17"); + __real_fsetpos64_2_2_5 = dlvsym (dlflag, "fsetpos64", "GLIBC_2.2.5"); + __real_fsetpos64_2_2 = dlvsym (dlflag, "fsetpos64", "GLIBC_2.2"); + __real_fsetpos64_2_1 = dlvsym (dlflag, "fsetpos64", "GLIBC_2.1"); + if (__real_fsetpos64_2_17) + __real_fsetpos64 = __real_fsetpos64_2_17; + else if (__real_fsetpos64_2_2_5) + __real_fsetpos64 = __real_fsetpos64_2_2_5; + else if (__real_fsetpos64_2_2) + __real_fsetpos64 = __real_fsetpos64_2_2; + else if (__real_fsetpos64_2_1) + __real_fsetpos64 = __real_fsetpos64_2_1; + else + __real_fsetpos64 = dlsym (dlflag, "fsetpos64"); + __real_pread_2_2 = dlvsym (dlflag, "pread", "GLIBC_2.2"); if (__real_pread_2_2) __real_pread = __real_pread_2_2; @@ -1001,21 +1016,21 @@ gprofng_open64 (int(real_open64) (const char *, int, ...), return fd; } -#define DCL_OPEN64(dcl_f, real_f) \ +#define DCL_OPEN64(dcl_f) \ int dcl_f (const char *path, int oflag, ...) \ { \ - if ((real_f) == NULL) \ + if (__real_open64 == NULL) \ init_io_intf (); \ mode_t mode; \ va_list ap; \ va_start (ap, oflag); \ mode = va_arg (ap, mode_t); \ va_end (ap); \ - return gprofng_open64 (real_f, path, oflag, mode); \ + return gprofng_open64 (__real_open64, path, oflag, mode); \ } DCL_FUNC_VER (DCL_OPEN64, open64_2_2, open64@GLIBC_2.2) -DCL_OPEN64 (open64, CALL_REAL(open64)) +DCL_OPEN64 (open64) #define F_ERROR_ARG 0 @@ -1516,19 +1531,19 @@ gprofng_fopen (FILE*(real_fopen) (), const char *filename, const char *mode) return fp; } -#define DCL_FOPEN(dcl_f, real_f) \ +#define DCL_FOPEN(dcl_f) \ FILE *dcl_f (const char *filename, const char *mode) \ { \ - if ((real_f) == NULL) \ + if (__real_fopen == NULL) \ init_io_intf (); \ - return gprofng_fopen (real_f, filename, mode); \ + return gprofng_fopen (__real_fopen, filename, mode); \ } DCL_FUNC_VER (DCL_FOPEN, fopen_2_17, fopen@GLIBC_2.17) DCL_FUNC_VER (DCL_FOPEN, fopen_2_2_5, fopen@GLIBC_2.2.5) DCL_FUNC_VER (DCL_FOPEN, fopen_2_1, fopen@GLIBC_2.1) DCL_FUNC_VER (DCL_FOPEN, fopen_2_0, fopen@GLIBC_2.0) -DCL_FOPEN (fopen, CALL_REAL(fopen)) +DCL_FOPEN (fopen) /*------------------------------------------------------------- fclose */ static int @@ -1564,19 +1579,19 @@ gprofng_fclose (int(real_fclose) (), FILE *stream) return stat; } -#define DCL_FCLOSE(dcl_f, real_f) \ +#define DCL_FCLOSE(dcl_f) \ int dcl_f (FILE *stream) \ { \ - if ((real_f) == NULL) \ + if (__real_fclose == NULL) \ init_io_intf (); \ - return gprofng_fclose (real_f, stream); \ + return gprofng_fclose (__real_fclose, stream); \ } DCL_FUNC_VER (DCL_FCLOSE, fclose_2_17, fclose@GLIBC_2.17) DCL_FUNC_VER (DCL_FCLOSE, fclose_2_2_5, fclose@GLIBC_2.2.5) DCL_FUNC_VER (DCL_FCLOSE, fclose_2_1, fclose@GLIBC_2.1) DCL_FUNC_VER (DCL_FCLOSE, fclose_2_0, fclose@GLIBC_2.0) -DCL_FCLOSE (fclose, CALL_REAL(fclose)) +DCL_FCLOSE (fclose) /*------------------------------------------------------------- fflush */ int @@ -1653,19 +1668,19 @@ gprofng_fdopen (FILE*(real_fdopen) (), int fildes, const char *mode) return fp; } -#define DCL_FDOPEN(dcl_f, real_f) \ +#define DCL_FDOPEN(dcl_f) \ FILE *dcl_f (int fildes, const char *mode) \ { \ - if ((real_f) == NULL) \ + if (__real_fdopen == NULL) \ init_io_intf (); \ - return gprofng_fdopen (real_f, fildes, mode); \ + return gprofng_fdopen (__real_fdopen, fildes, mode); \ } DCL_FUNC_VER (DCL_FDOPEN, fdopen_2_17, fdopen@GLIBC_2.17) DCL_FUNC_VER (DCL_FDOPEN, fdopen_2_2_5, fdopen@GLIBC_2.2.5) DCL_FUNC_VER (DCL_FDOPEN, fdopen_2_1, fdopen@GLIBC_2.1) DCL_FUNC_VER (DCL_FDOPEN, fdopen_2_0, fdopen@GLIBC_2.0) -DCL_FDOPEN (fdopen, CALL_REAL(fdopen)) +DCL_FDOPEN (fdopen) /*------------------------------------------------------------- dup */ int @@ -2088,16 +2103,16 @@ gprofng_pread (ssize_t(real_pread) (int, void *, size_t, off_t), return ret; } -#define DCL_PREAD(dcl_f, real_f) \ +#define DCL_PREAD(dcl_f) \ ssize_t dcl_f (int fildes, void *buf, size_t nbyte, off_t offset) \ { \ - if ((real_f) == NULL) \ + if (__real_pread == NULL) \ init_io_intf (); \ - return gprofng_pread (real_f, fildes, buf, nbyte, offset); \ + return gprofng_pread (__real_pread, fildes, buf, nbyte, offset); \ } DCL_FUNC_VER (DCL_PREAD, pread_2_2, pread@GLIBC_2.2) -DCL_PREAD (pread, CALL_REAL(pread)) +DCL_PREAD (pread) /*------------------------------------------------------------- pwrite */ @@ -2914,19 +2929,19 @@ gprofng_fgetpos (int(real_fgetpos) (FILE *stream, fpos_t *pos), return ret; } -#define DCL_FGETPOS(dcl_f, real_f) \ +#define DCL_FGETPOS(dcl_f) \ int dcl_f (FILE *stream, fpos_t *pos) \ { \ - if ((real_f) == NULL) \ + if (__real_fgetpos == NULL) \ init_io_intf (); \ - return gprofng_fgetpos (real_f, stream, pos); \ + return gprofng_fgetpos (__real_fgetpos, stream, pos); \ } DCL_FUNC_VER (DCL_FGETPOS, fgetpos_2_17, fgetpos@GLIBC_2.17) DCL_FUNC_VER (DCL_FGETPOS, fgetpos_2_2_5, fgetpos@GLIBC_2.2.5) DCL_FUNC_VER (DCL_FGETPOS, fgetpos_2_2, fgetpos@GLIBC_2.2) DCL_FUNC_VER (DCL_FGETPOS, fgetpos_2_0, fgetpos@GLIBC_2.0) -DCL_FGETPOS (fgetpos, CALL_REAL(fgetpos)) +DCL_FGETPOS (fgetpos) /*------------------------------------------------------------- fgetpos64 */ static int @@ -2962,19 +2977,19 @@ gprofng_fgetpos64 (int(real_fgetpos64) (), FILE *stream, fpos64_t *pos) return ret; } -#define DCL_FGETPOS64(dcl_f, real_f) \ +#define DCL_FGETPOS64(dcl_f) \ int dcl_f (FILE *stream, fpos64_t *pos) \ { \ - if ((real_f) == NULL) \ + if (__real_fgetpos64 == NULL) \ init_io_intf (); \ - return gprofng_fgetpos64 (real_f, stream, pos); \ + return gprofng_fgetpos64 (__real_fgetpos64, stream, pos); \ } DCL_FUNC_VER (DCL_FGETPOS64, fgetpos64_2_17, fgetpos64@GLIBC_2.17) DCL_FUNC_VER (DCL_FGETPOS64, fgetpos64_2_2_5, fgetpos64@GLIBC_2.2.5) DCL_FUNC_VER (DCL_FGETPOS64, fgetpos64_2_2, fgetpos64@GLIBC_2.2) DCL_FUNC_VER (DCL_FGETPOS64, fgetpos64_2_1, fgetpos64@GLIBC_2.1) -DCL_FGETPOS64 (fgetpos64, CALL_REAL(fgetpos64)) +DCL_FGETPOS64 (fgetpos64) /*------------------------------------------------------------- fsetpos */ static int @@ -3011,19 +3026,19 @@ gprofng_fsetpos (int(real_fsetpos) (FILE *, const fpos_t *), return ret; } -#define DCL_FSETPOS(dcl_f, real_f) \ +#define DCL_FSETPOS(dcl_f) \ int dcl_f (FILE *stream, const fpos_t *pos) \ { \ - if ((real_f) == NULL) \ + if (__real_fsetpos == NULL) \ init_io_intf (); \ - return gprofng_fsetpos (real_f, stream, pos); \ + return gprofng_fsetpos (__real_fsetpos, stream, pos); \ } DCL_FUNC_VER (DCL_FSETPOS, fsetpos_2_17, fsetpos@GLIBC_2.17) DCL_FUNC_VER (DCL_FSETPOS, fsetpos_2_2_5, fsetpos@GLIBC_2.2.5) DCL_FUNC_VER (DCL_FSETPOS, fsetpos_2_2, fsetpos@GLIBC_2.2) DCL_FUNC_VER (DCL_FSETPOS, fsetpos_2_0, fsetpos@GLIBC_2.0) -DCL_FSETPOS (fsetpos, CALL_REAL(fsetpos)) +DCL_FSETPOS (fsetpos) /*------------------------------------------------------------- fsetpos64 */ static int @@ -3060,19 +3075,19 @@ gprofng_fsetpos64 (int(real_fsetpos64) (FILE *, const fpos64_t *), return ret; } -#define DCL_FSETPOS64(dcl_f, real_f) \ +#define DCL_FSETPOS64(dcl_f) \ int dcl_f (FILE *stream, const fpos64_t *pos) \ { \ - if ((real_f) == NULL) \ + if (__real_fsetpos64 == NULL) \ init_io_intf (); \ - return gprofng_fsetpos64 (real_f, stream, pos); \ + return gprofng_fsetpos64 (__real_fsetpos64, stream, pos); \ } DCL_FUNC_VER (DCL_FSETPOS64, fsetpos64_2_17, fsetpos64@GLIBC_2.17) DCL_FUNC_VER (DCL_FSETPOS64, fsetpos64_2_2_5, fsetpos64@GLIBC_2.2.5) DCL_FUNC_VER (DCL_FSETPOS64, fsetpos64_2_2, fsetpos64@GLIBC_2.2) DCL_FUNC_VER (DCL_FSETPOS64, fsetpos64_2_1, fsetpos64@GLIBC_2.1) -DCL_FSETPOS64 (fsetpos64, CALL_REAL(fsetpos64)) +DCL_FSETPOS64 (fsetpos64) /*------------------------------------------------------------- fsync */ int diff --git a/gprofng/libcollector/linetrace.c b/gprofng/libcollector/linetrace.c index b29e0b93591..917bc95f6c9 100644 --- a/gprofng/libcollector/linetrace.c +++ b/gprofng/libcollector/linetrace.c @@ -682,8 +682,6 @@ init_lineage_intf () __real_execlp = dlsym (dlflag, "execlp"); __real_execl = dlsym (dlflag, "execl"); __real_clone = dlsym (dlflag, "clone"); - __real_posix_spawn = dlsym (dlflag, "posix_spawn"); - __real_posix_spawnp = dlsym (dlflag, "posix_spawnp"); __real_popen_2_17 = dlvsym (dlflag, "popen", "GLIBC_2.17"); __real_popen_2_2_5 = dlvsym (dlflag, "popen", "GLIBC_2.2.5"); @@ -704,11 +702,31 @@ init_lineage_intf () __real_posix_spawn_2_15 = dlvsym (dlflag, "posix_spawn", "GLIBC_2.15"); __real_posix_spawn_2_2_5 = dlvsym (dlflag, "posix_spawn", "GLIBC_2.2.5"); __real_posix_spawn_2_2 = dlvsym (dlflag, "posix_spawn", "GLIBC_2.2"); + if (__real_posix_spawn_2_17) + __real_posix_spawn = __real_posix_spawn_2_17; + else if (__real_posix_spawn_2_15) + __real_posix_spawn = __real_posix_spawn_2_15; + else if (__real_posix_spawn_2_2_5) + __real_posix_spawn = __real_posix_spawn_2_2_5; + else if (__real_posix_spawn_2_2) + __real_posix_spawn = __real_posix_spawn_2_2; + else + __real_posix_spawn = dlsym (dlflag, "posix_spawn"); __real_posix_spawnp_2_17 = dlvsym (dlflag, "posix_spawnp", "GLIBC_2.17"); __real_posix_spawnp_2_15 = dlvsym (dlflag, "posix_spawnp", "GLIBC_2.15"); __real_posix_spawnp_2_2_5 = dlvsym (dlflag, "posix_spawnp", "GLIBC_2.2.5"); __real_posix_spawnp_2_2 = dlvsym (dlflag, "posix_spawnp", "GLIBC_2.2"); + if (__real_posix_spawnp_2_17) + __real_posix_spawnp = __real_posix_spawnp_2_17; + else if (__real_posix_spawnp_2_15) + __real_posix_spawnp = __real_posix_spawnp_2_15; + else if (__real_posix_spawnp_2_2_5) + __real_posix_spawnp = __real_posix_spawnp_2_2_5; + else if (__real_posix_spawnp_2_2) + __real_posix_spawnp = __real_posix_spawnp_2_2; + else + __real_posix_spawnp = dlsym (dlflag, "posix_spawnp"); __real_grantpt = dlsym (dlflag, "grantpt"); __real_ptsname = dlsym (dlflag, "ptsname"); @@ -1427,16 +1445,16 @@ gprofng_posix_spawn (int(real_posix_spawn) (), return ret; } -#define DCL_POSIX_SPAWN(dcl_f, real_f) \ +#define DCL_POSIX_SPAWN(dcl_f) \ int dcl_f (pid_t *pidp, const char *path, \ const posix_spawn_file_actions_t *file_actions, \ const posix_spawnattr_t *attrp, \ char *const argv[], char *const envp[]) \ { \ - if ((real_f) == NULL) \ + if (__real_posix_spawn == NULL) \ init_lineage_intf (); \ - return gprofng_posix_spawn (real_f, pidp, path, file_actions, attrp, \ - argv, envp); \ + return gprofng_posix_spawn (__real_posix_spawn, pidp, path, file_actions, \ + attrp, argv, envp); \ } @@ -1444,7 +1462,7 @@ DCL_FUNC_VER (DCL_POSIX_SPAWN, posix_spawn_2_17, posix_spawn@GLIBC_2.17) DCL_FUNC_VER (DCL_POSIX_SPAWN, posix_spawn_2_15, posix_spawn@GLIBC_2.15) DCL_FUNC_VER (DCL_POSIX_SPAWN, posix_spawn_2_2_5, posix_spawn@GLIBC_2.2.5) DCL_FUNC_VER (DCL_POSIX_SPAWN, posix_spawn_2_2, posix_spawn@GLIBC_2.2) -DCL_POSIX_SPAWN (posix_spawn, CALL_REAL (posix_spawn)) +DCL_POSIX_SPAWN (posix_spawn) /*-------------------------------------------------------- posix_spawnp */ static int @@ -1484,15 +1502,15 @@ gprofng_posix_spawnp (int (real_posix_spawnp) (), return ret; } -#define DCL_POSIX_SPAWNP(dcl_f, real_f) \ +#define DCL_POSIX_SPAWNP(dcl_f) \ int dcl_f (pid_t *pidp, const char *path, \ const posix_spawn_file_actions_t *file_actions, \ const posix_spawnattr_t *attrp, \ char *const argv[], char *const envp[]) \ { \ - if ((real_f) == NULL) \ + if (__real_posix_spawnp == NULL) \ init_lineage_intf (); \ - return gprofng_posix_spawnp (real_f, pidp, path, \ + return gprofng_posix_spawnp (__real_posix_spawnp, pidp, path, \ file_actions, attrp, argv, envp); \ } @@ -1500,7 +1518,7 @@ DCL_FUNC_VER (DCL_POSIX_SPAWNP, posix_spawnp_2_17, posix_spawnp@GLIBC_2.17) DCL_FUNC_VER (DCL_POSIX_SPAWNP, posix_spawnp_2_15, posix_spawnp@GLIBC_2.15) DCL_FUNC_VER (DCL_POSIX_SPAWNP, posix_spawnp_2_2_5, posix_spawnp@GLIBC_2.2.5) DCL_FUNC_VER (DCL_POSIX_SPAWNP, posix_spawnp_2_2, posix_spawnp@GLIBC_2.2) -DCL_POSIX_SPAWNP (posix_spawnp, CALL_REAL (posix_spawnp)) +DCL_POSIX_SPAWNP (posix_spawnp) /*------------------------------------------------------------- system */ int system () __attribute__ ((weak, alias ("__collector_system"))); @@ -1529,10 +1547,10 @@ __collector_system (const char *cmd) /*------------------------------------------------------------- popen */ // map interposed symbol versions -#define DCL_POPEN(dcl_f, real_f) \ +#define DCL_POPEN(dcl_f) \ FILE *dcl_f (const char *cmd, const char *mode) \ { \ - if ((real_f) == NULL) \ + if (__real_popen == NULL) \ init_lineage_intf (); \ TprintfT (DBG_LT0, #dcl_f " (%s) interposing: line_mode=%d combo=%d\n", \ cmd ? cmd : "NULL", line_mode, get_combo_flag ()); \ @@ -1540,11 +1558,11 @@ __collector_system (const char *cmd) if (line_mode == LM_TRACK_LINEAGE) \ INIT_REENTRANCE (guard); \ if (guard == NULL) \ - return (real_f) (cmd, mode); \ + return __real_popen (cmd, mode); \ int following_combo = 0; \ linetrace_ext_combo_prologue ("popen", cmd, &following_combo); \ PUSH_REENTRANCE (guard); \ - FILE *ret = (real_f) (cmd, mode); \ + FILE *ret = __real_popen (cmd, mode); \ POP_REENTRANCE (guard); \ linetrace_ext_combo_epilogue ("popen", ret == NULL ? -1 : 0, \ &following_combo); \ @@ -1555,7 +1573,7 @@ DCL_FUNC_VER (DCL_POPEN, popen_2_17, popen@GLIBC_2.17) DCL_FUNC_VER (DCL_POPEN, popen_2_2_5, popen@GLIBC_2.2.5) DCL_FUNC_VER (DCL_POPEN, popen_2_1, popen@GLIBC_2.1) DCL_FUNC_VER (DCL_POPEN, popen_2_0, popen@GLIBC_2.0) -DCL_POPEN (popen, CALL_REAL (popen)) +DCL_POPEN (popen) /*------------------------------------------------------------- grantpt */ int grantpt () __attribute__ ((weak, alias ("__collector_grantpt"))); diff --git a/gprofng/libcollector/mmaptrace.c b/gprofng/libcollector/mmaptrace.c index f81ff8db1df..b7ad2dbe08f 100644 --- a/gprofng/libcollector/mmaptrace.c +++ b/gprofng/libcollector/mmaptrace.c @@ -1609,13 +1609,13 @@ gprofng_dlopen (void*(real_dlopen) (const char *, int), return ret; } -#define DCL_DLOPEN(dcl_f, real_f) \ +#define DCL_DLOPEN(dcl_f) \ void *dcl_f (const char *pathname, int mode) \ { \ - if ((real_f) == NULL) \ + if (__real_dlopen == NULL) \ init_mmap_intf (); \ void *caller = __builtin_return_address (0); \ - return gprofng_dlopen (real_f, caller, pathname, mode); \ + return gprofng_dlopen (__real_dlopen, caller, pathname, mode); \ } DCL_FUNC_VER (DCL_DLOPEN, dlopen_2_34, dlopen@GLIBC_2.34) @@ -1623,7 +1623,7 @@ DCL_FUNC_VER (DCL_DLOPEN, dlopen_2_17, dlopen@GLIBC_2.17) DCL_FUNC_VER (DCL_DLOPEN, dlopen_2_2_5, dlopen@GLIBC_2.2.5) DCL_FUNC_VER (DCL_DLOPEN, dlopen_2_1, dlopen@GLIBC_2.1) DCL_FUNC_VER (DCL_DLOPEN, dlopen_2_0, dlopen@GLIBC_2.0) -DCL_DLOPEN (dlopen, CALL_REAL (dlopen)) +DCL_DLOPEN (dlopen) /*------------------------------------------------------------- dlclose */ static int @@ -1651,16 +1651,16 @@ gprofng_dlclose (int (real_dlclose) (void *), void *handle) return ret; } -#define DCL_DLCLOSE(dcl_f, real_f) \ +#define DCL_DLCLOSE(dcl_f) \ int dcl_f (void *handle) \ { \ - if ((real_f) == NULL) \ + if (__real_dlclose == NULL) \ init_mmap_intf (); \ - return gprofng_dlclose (real_f, handle); \ + return gprofng_dlclose (__real_dlclose, handle); \ } DCL_FUNC_VER (DCL_DLCLOSE, dlclose_2_34, dlclose@GLIBC_2.34) DCL_FUNC_VER (DCL_DLCLOSE, dlclose_2_17, dlclose@GLIBC_2.17) DCL_FUNC_VER (DCL_DLCLOSE, dlclose_2_2_5, dlclose@GLIBC_2.2.5) DCL_FUNC_VER (DCL_DLCLOSE, dlclose_2_0, dlclose@GLIBC_2.0) -DCL_DLCLOSE (dlclose, CALL_REAL (dlclose)) +DCL_DLCLOSE (dlclose) diff --git a/gprofng/libcollector/synctrace.c b/gprofng/libcollector/synctrace.c index a00691fd958..565afbe742f 100644 --- a/gprofng/libcollector/synctrace.c +++ b/gprofng/libcollector/synctrace.c @@ -607,18 +607,18 @@ gprofng_pthread_mutex_lock (int (real_func) (pthread_mutex_t *), return ret; } -#define DCL_PTHREAD_MUTEX_LOCK(dcl_f, real_f) \ +#define DCL_PTHREAD_MUTEX_LOCK(dcl_f) \ int dcl_f (pthread_mutex_t *mp) \ { \ - if ((real_f) == NULL) \ + if (__real_pthread_mutex_lock == NULL) \ init_thread_intf (); \ - return gprofng_pthread_mutex_lock (real_f, mp); \ + return gprofng_pthread_mutex_lock (__real_pthread_mutex_lock, mp); \ } DCL_FUNC_VER (DCL_PTHREAD_MUTEX_LOCK, pthread_mutex_lock_2_17, pthread_mutex_lock@GLIBC_2.17) DCL_FUNC_VER (DCL_PTHREAD_MUTEX_LOCK, pthread_mutex_lock_2_2_5, pthread_mutex_lock@GLIBC_2.2.5) DCL_FUNC_VER (DCL_PTHREAD_MUTEX_LOCK, pthread_mutex_lock_2_0, pthread_mutex_lock@GLIBC_2.0) -DCL_PTHREAD_MUTEX_LOCK (pthread_mutex_lock, CALL_REAL (pthread_mutex_lock)) +DCL_PTHREAD_MUTEX_LOCK (pthread_mutex_lock) /*------------------------------------------------------------- pthread_cond_wait */ static int @@ -654,19 +654,19 @@ gprofng_pthread_cond_wait (int(real_func) (pthread_cond_t *, pthread_mutex_t *), return ret; } -#define DCL_PTHREAD_COND_WAIT(dcl_f, real_f) \ +#define DCL_PTHREAD_COND_WAIT(dcl_f) \ int dcl_f (pthread_cond_t *cond, pthread_mutex_t *mutex) \ { \ - if ((real_f) == NULL) \ + if (__real_pthread_cond_wait == NULL) \ init_thread_intf (); \ - return gprofng_pthread_cond_wait (real_f, cond, mutex); \ + return gprofng_pthread_cond_wait (__real_pthread_cond_wait, cond, mutex); \ } DCL_FUNC_VER (DCL_PTHREAD_COND_WAIT, pthread_cond_wait_2_17, pthread_cond_wait@GLIBC_2.17) DCL_FUNC_VER (DCL_PTHREAD_COND_WAIT, pthread_cond_wait_2_3_2, pthread_cond_wait@GLIBC_2.3.2) DCL_FUNC_VER (DCL_PTHREAD_COND_WAIT, pthread_cond_wait_2_2_5, pthread_cond_wait@GLIBC_2.2.5) DCL_FUNC_VER (DCL_PTHREAD_COND_WAIT, pthread_cond_wait_2_0, pthread_cond_wait@GLIBC_2.0) -DCL_PTHREAD_COND_WAIT (pthread_cond_wait, CALL_REAL (pthread_cond_wait)) +DCL_PTHREAD_COND_WAIT (pthread_cond_wait) /*---------------------------------------------------- pthread_cond_timedwait */ static int @@ -704,20 +704,20 @@ gprofng_pthread_cond_timedwait (int(real_func) (pthread_cond_t *, return ret; } -#define DCL_PTHREAD_COND_TIMEDWAIT(dcl_f, real_f) \ +#define DCL_PTHREAD_COND_TIMEDWAIT(dcl_f) \ int dcl_f (pthread_cond_t *cond, pthread_mutex_t *mutex, \ const struct timespec *abstime) \ { \ - if ((real_f) == NULL) \ + if (__real_pthread_cond_timedwait == NULL) \ init_thread_intf (); \ - return gprofng_pthread_cond_timedwait (real_f, cond, mutex, abstime); \ + return gprofng_pthread_cond_timedwait (__real_pthread_cond_timedwait, cond, mutex, abstime); \ } DCL_FUNC_VER (DCL_PTHREAD_COND_TIMEDWAIT, pthread_cond_timedwait_2_17, pthread_cond_timedwait@GLIBC_2.17) DCL_FUNC_VER (DCL_PTHREAD_COND_TIMEDWAIT, pthread_cond_timedwait_2_3_2, pthread_cond_timedwait@GLIBC_2.3.2) DCL_FUNC_VER (DCL_PTHREAD_COND_TIMEDWAIT, pthread_cond_timedwait_2_2_5, pthread_cond_timedwait@GLIBC_2.2.5) DCL_FUNC_VER (DCL_PTHREAD_COND_TIMEDWAIT, pthread_cond_timedwait_2_0, pthread_cond_timedwait@GLIBC_2.0) -DCL_PTHREAD_COND_TIMEDWAIT (pthread_cond_timedwait, CALL_REAL (pthread_cond_timedwait)) +DCL_PTHREAD_COND_TIMEDWAIT (pthread_cond_timedwait) /*------------------------------------------------------------- pthread_join */ @@ -753,19 +753,19 @@ gprofng_pthread_join (int(real_func) (pthread_t, void **), return ret; } -#define DCL_PTHREAD_JOIN(dcl_f, real_f) \ +#define DCL_PTHREAD_JOIN(dcl_f) \ int dcl_f (pthread_t target_thread, void **status) \ { \ - if ((real_f) == NULL) \ + if (__real_pthread_join == NULL) \ init_thread_intf (); \ - return gprofng_pthread_join (real_f, target_thread, status); \ + return gprofng_pthread_join (__real_pthread_join, target_thread, status); \ } DCL_FUNC_VER (DCL_PTHREAD_JOIN, pthread_join_2_34, pthread_join@GLIBC_2.34) DCL_FUNC_VER (DCL_PTHREAD_JOIN, pthread_join_2_17, pthread_join@GLIBC_2.17) DCL_FUNC_VER (DCL_PTHREAD_JOIN, pthread_join_2_2_5, pthread_join@GLIBC_2.2.5) DCL_FUNC_VER (DCL_PTHREAD_JOIN, pthread_join_2_0, pthread_join@GLIBC_2.0) -DCL_PTHREAD_JOIN (pthread_join, CALL_REAL (pthread_join)) +DCL_PTHREAD_JOIN (pthread_join) /*------------------------------------------------------------- sem_wait */ static int @@ -800,12 +800,12 @@ gprofng_sem_wait (int (real_func) (sem_t *), sem_t *sp) return ret; } -#define DCL_SEM_WAIT(dcl_f, real_f) \ +#define DCL_SEM_WAIT(dcl_f) \ int dcl_f (sem_t *sp) \ { \ - if ((real_f) == NULL) \ + if (__real_sem_wait == NULL) \ init_thread_intf (); \ - return gprofng_sem_wait (real_f, sp); \ + return gprofng_sem_wait (__real_sem_wait, sp); \ } DCL_FUNC_VER (DCL_SEM_WAIT, sem_wait_2_34, sem_wait@GLIBC_2.34) @@ -813,4 +813,4 @@ DCL_FUNC_VER (DCL_SEM_WAIT, sem_wait_2_17, sem_wait@GLIBC_2.17) DCL_FUNC_VER (DCL_SEM_WAIT, sem_wait_2_2_5, sem_wait@GLIBC_2.2.5) DCL_FUNC_VER (DCL_SEM_WAIT, sem_wait_2_0, sem_wait@GLIBC_2.0) DCL_FUNC_VER (DCL_SEM_WAIT, sem_wait_2_1, sem_wait@GLIBC_2.1) -DCL_SEM_WAIT (sem_wait, CALL_REAL (sem_wait)) +DCL_SEM_WAIT (sem_wait) -- 2.30.2