gprofng: 30089 [display text] Invalid number of threads

The real problem is that libcollector doesn't interpose thread_create@GLIBC_2.34
We interpose a lot of libC functions (dlopen, fork, pthread_create, etc.).
Some of these functions have versions. For example, dlopen@GLIBC_2.34,
dlopen@GLIBC_2.17, dlopen@GLIBC_2.2.5, etc.
We have to interpose each of the functions because we don't know
which version of libC will be used during profiling.
Historically, we have used three versions of scripts (mapfile.aarch64-Linux,
mapfile.amd64-Linux, mapfile.intel-Linux).
Three are not needed. One is enough

The fixes below include:
 - merged all version symbols into one version script.
 - added new version symbols which are defined in latest versions of libC.
 - removed unused defines and duplicated code.
 - added the DCL_FUNC_VER macro to define the version symbols.

Tested on x86_64 and aarch64 (OL8/OL9). No regression.

gprofng/ChangeLog
2023-03-23  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/30089
	* libcollector/Makefile.am: Use libgprofng.ver instead of mapfile.*
	* libcollector/configure.ac: Delete GPROFNG_VARIANT.
	* src/collector_module.h: Move the SYMVER_ATTRIBUTE macro to collector.h
	* libcollector/collector.h: Add macros (SYMVER_ATTRIBUTE, DCL_FUNC_VER).
	Remove unused defines.
	* libcollector/dispatcher.c: Interpose functions from libC.
	Clean up the old code.
	* libcollector/iotrace.c: Likewise.
	* libcollector/libcol_util.c: Likewise.
	* libcollector/linetrace.c: Likewise.
	* libcollector/mmaptrace.c: Likewise.
	* libcollector/synctrace.c: Likewise.
	* libcollector/libgprofng.ver: New file.
	* libcollector/Makefile.in: Rebuild.
	* libcollector/configure: Rebuild.
	* libcollector/mapfile.aarch64-Linux: Removed.
	* libcollector/mapfile.amd64-Linux: Removed.
	* libcollector/mapfile.intel-Linux: Removed.
	* libcollector/mapfile.sparc-Linux: Removed.
	* libcollector/mapfile.sparcv9-Linux: Removed.
This commit is contained in:
Vladimir Mezentsev
2023-03-23 11:46:08 -07:00
parent 57573e54af
commit 66f76c545b
18 changed files with 1247 additions and 2357 deletions

View File

@@ -40,12 +40,6 @@
#include "memmgr.h" // __collector_allocCSize, __collector_freeCSize
#include "tsd.h"
/* TprintfT(<level>,...) definitions. Adjust per module as needed */
#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings
#define DBG_LT1 1 // for configuration details, warnings
#define DBG_LT2 2
#define DBG_LT3 3
/*
* This file is intended for collector's own implementation of
* various routines to avoid interaction with libc and other
@@ -1456,54 +1450,53 @@ __collector_util_init ()
/* don't treat this as fatal, so that S10 could work */
}
#if ARCH(Intel) && WSIZE(32)
ptr = dlvsym (libc, "fopen", "GLIBC_2.1");
if (ptr)
__collector_util_funcs.fopen = (FILE * (*)())ptr;
if ((ptr = dlvsym (libc, "fopen", "GLIBC_2.17")) != NULL)
__collector_util_funcs.fopen = ptr;
else if ((ptr = dlvsym (libc, "fopen", "GLIBC_2.2.5")) != NULL)
__collector_util_funcs.fopen = ptr;
else if ((ptr = dlvsym (libc, "fopen", "GLIBC_2.1")) != NULL)
__collector_util_funcs.fopen = ptr;
else if ((ptr = dlvsym (libc, "fopen", "GLIBC_2.0")) != NULL)
__collector_util_funcs.fopen = ptr;
else
ptr = dlsym (libc, "fopen");
if (__collector_util_funcs.fopen == NULL)
{
Tprintf (DBG_LT0, "libcol_util: WARNING: dlvsym for %s@%s failed. Using dlsym() instead.", "fopen", "GLIBC_2.1");
#endif /* ARCH(Intel) && WSIZE(32) */
ptr = dlsym (libc, "fopen");
if (ptr)
__collector_util_funcs.fopen = (FILE * (*)())ptr;
else
{
CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT fopen: %s\n", dlerror ());
err = COL_ERROR_UTIL_INIT;
}
#if ARCH(Intel) && WSIZE(32)
}
#endif
ptr = dlsym (libc, "popen");
if (ptr)
__collector_util_funcs.popen = (FILE * (*)())ptr;
else
{
CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT popen: %s\n", dlerror ());
CALL_UTIL (fprintf)(stderr, "COL_ERROR_UTIL_INIT fopen: %s\n", dlerror ());
err = COL_ERROR_UTIL_INIT;
}
#if ARCH(Intel) && WSIZE(32)
ptr = dlvsym (libc, "fclose", "GLIBC_2.1");
if (ptr)
__collector_util_funcs.fclose = (int(*)())ptr;
if ((ptr = dlvsym (libc, "popen", "GLIBC_2.17")) != NULL)
__collector_util_funcs.popen = ptr;
else if ((ptr = dlvsym (libc, "popen", "GLIBC_2.2.5")) != NULL)
__collector_util_funcs.popen = ptr;
else if ((ptr = dlvsym (libc, "popen", "GLIBC_2.1")) != NULL)
__collector_util_funcs.popen = ptr;
else if ((ptr = dlvsym (libc, "popen", "GLIBC_2.0")) != NULL)
__collector_util_funcs.popen = ptr;
else
ptr = dlsym (libc, "popen");
if (__collector_util_funcs.popen == NULL)
{
Tprintf (DBG_LT0, "libcol_util: WARNING: dlvsym for %s@%s failed. Using dlsym() instead.", "fclose", "GLIBC_2.1");
#endif /* ARCH(Intel) && WSIZE(32) */
ptr = dlsym (libc, "fclose");
if (ptr)
__collector_util_funcs.fclose = (int(*)())ptr;
else
{
CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT fclose: %s\n", dlerror ());
err = COL_ERROR_UTIL_INIT;
}
#if ARCH(Intel) && WSIZE(32)
CALL_UTIL (fprintf)(stderr, "COL_ERROR_UTIL_INIT popen: %s\n", dlerror ());
err = COL_ERROR_UTIL_INIT;
}
if ((ptr = dlvsym (libc, "fclose", "GLIBC_2.17")) != NULL)
__collector_util_funcs.fclose = ptr;
else if ((ptr = dlvsym (libc, "fclose", "GLIBC_2.2.5")) != NULL)
__collector_util_funcs.fclose = ptr;
else if ((ptr = dlvsym (libc, "fclose", "GLIBC_2.1")) != NULL)
__collector_util_funcs.fclose = ptr;
else if ((ptr = dlvsym (libc, "fclose", "GLIBC_2.0")) != NULL)
__collector_util_funcs.fclose = ptr;
else
ptr = dlsym (libc, "fclose");
if (__collector_util_funcs.fclose == NULL)
{
CALL_UTIL (fprintf)(stderr, "COL_ERROR_UTIL_INIT fclose: %s\n", dlerror ());
err = COL_ERROR_UTIL_INIT;
}
#endif
ptr = dlsym (libc, "pclose");
if (ptr)