diff options
author | dsamersoff <unknown> | 2014-06-13 05:10:44 -0700 |
---|---|---|
committer | bell-sw <liberica@bell-sw.com> | 2019-10-23 16:22:28 +0300 |
commit | bd83d7cf987b561bdf1cf1cb1cb52f2a786d0ae2 (patch) | |
tree | af5fd43f4ffd4c888ef53d5df3de31cf888c2407 | |
parent | e72c9665f8d7cd778937840bacd5cbedf1e95714 (diff) | |
download | jdk8u_hotspot-bd83d7cf987b561bdf1cf1cb1cb52f2a786d0ae2.tar.gz |
8038392: Generating prelink cache breaks JAVA 'jinfo' utility normal behaviour
Summary: Better parsing of /proc/pid/maps in sa
Reviewed-by: sspitsyn, sla
-rw-r--r-- | agent/src/os/linux/ps_proc.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/agent/src/os/linux/ps_proc.c b/agent/src/os/linux/ps_proc.c index abf2d60fd..c4d6a9ecc 100644 --- a/agent/src/os/linux/ps_proc.c +++ b/agent/src/os/linux/ps_proc.c @@ -345,7 +345,7 @@ static bool add_new_thread(struct ps_prochandle* ph, pthread_t pthread_id, lwpid static bool read_lib_info(struct ps_prochandle* ph) { char fname[32]; - char buf[256]; + char buf[PATH_MAX]; FILE *fp = NULL; sprintf(fname, "/proc/%d/maps", ph->pid); @@ -355,10 +355,41 @@ static bool read_lib_info(struct ps_prochandle* ph) { return false; } - while(fgets_no_cr(buf, 256, fp)){ - char * word[6]; - int nwords = split_n_str(buf, 6, word, ' ', '\0'); - if (nwords > 5 && find_lib(ph, word[5]) == false) { + while(fgets_no_cr(buf, PATH_MAX, fp)){ + char * word[7]; + int nwords = split_n_str(buf, 7, word, ' ', '\0'); + + if (nwords < 6) { + // not a shared library entry. ignore. + continue; + } + + // SA does not handle the lines with patterns: + // "[stack]", "[heap]", "[vdso]", "[vsyscall]", etc. + if (word[5][0] == '[') { + // not a shared library entry. ignore. + continue; + } + + if (nwords > 6) { + // prelink altered mapfile when the program is running. + // Entries like one below have to be skipped + // /lib64/libc-2.15.so (deleted) + // SO name in entries like one below have to be stripped. + // /lib64/libpthread-2.15.so.#prelink#.EECVts + char *s = strstr(word[5],".#prelink#"); + if (s == NULL) { + // No prelink keyword. skip deleted library + print_debug("skip shared object %s deleted by prelink\n", word[5]); + continue; + } + + // Fall through + print_debug("rectifying shared object name %s changed by prelink\n", word[5]); + *s = 0; + } + + if (find_lib(ph, word[5]) == false) { intptr_t base; lib_info* lib; #ifdef _LP64 |