diff options
author | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2023-04-16 13:55:48 -0700 |
---|---|---|
committer | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2023-04-17 13:01:38 -0700 |
commit | 35fab451d9ec11a7e02df750fb24feb21e9732b8 (patch) | |
tree | 64f9f7b28c6ac6a1a300ad29e2c1455ec952333d /gprofng/libcollector/mmaptrace.c | |
parent | 7a515757db9681e86926b7068b3a4a6a2df70299 (diff) | |
download | fsf-binutils-gdb-35fab451d9ec11a7e02df750fb24feb21e9732b8.zip fsf-binutils-gdb-35fab451d9ec11a7e02df750fb24feb21e9732b8.tar.gz fsf-binutils-gdb-35fab451d9ec11a7e02df750fb24feb21e9732b8.tar.bz2 |
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_<NN>,
we use dlvsym (dlflag, "pthread_create", "GLIBC_<NN>") 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 <vladimir.mezentsev@oracle.com>
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.
Diffstat (limited to 'gprofng/libcollector/mmaptrace.c')
-rw-r--r-- | gprofng/libcollector/mmaptrace.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/gprofng/libcollector/mmaptrace.c b/gprofng/libcollector/mmaptrace.c index f81ff8d..b7ad2db 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) |