8038392: Generating prelink cache breaks JAVA 'jinfo' utility normal behaviour jdk8u232-b07

Fri, 13 Jun 2014 05:10:44 -0700

author
dsamersoff
date
Fri, 13 Jun 2014 05:10:44 -0700
changeset 9751
c751303497d5
parent 9750
3ece33697a35
child 9752
1aa54ae51b56

8038392: Generating prelink cache breaks JAVA 'jinfo' utility normal behaviour
Summary: Better parsing of /proc/pid/maps in sa
Reviewed-by: sspitsyn, sla

agent/src/os/linux/ps_proc.c file | annotate | diff | comparison | revisions
     1.1 --- a/agent/src/os/linux/ps_proc.c	Mon Sep 16 18:07:11 2019 +0100
     1.2 +++ b/agent/src/os/linux/ps_proc.c	Fri Jun 13 05:10:44 2014 -0700
     1.3 @@ -345,7 +345,7 @@
     1.4  
     1.5  static bool read_lib_info(struct ps_prochandle* ph) {
     1.6    char fname[32];
     1.7 -  char buf[256];
     1.8 +  char buf[PATH_MAX];
     1.9    FILE *fp = NULL;
    1.10  
    1.11    sprintf(fname, "/proc/%d/maps", ph->pid);
    1.12 @@ -355,10 +355,41 @@
    1.13      return false;
    1.14    }
    1.15  
    1.16 -  while(fgets_no_cr(buf, 256, fp)){
    1.17 -    char * word[6];
    1.18 -    int nwords = split_n_str(buf, 6, word, ' ', '\0');
    1.19 -    if (nwords > 5 && find_lib(ph, word[5]) == false) {
    1.20 +  while(fgets_no_cr(buf, PATH_MAX, fp)){
    1.21 +    char * word[7];
    1.22 +    int nwords = split_n_str(buf, 7, word, ' ', '\0');
    1.23 +
    1.24 +    if (nwords < 6) {
    1.25 +      // not a shared library entry. ignore.
    1.26 +      continue;
    1.27 +    }
    1.28 +
    1.29 +    // SA does not handle the lines with patterns:
    1.30 +    //   "[stack]", "[heap]", "[vdso]", "[vsyscall]", etc.
    1.31 +    if (word[5][0] == '[') {
    1.32 +        // not a shared library entry. ignore.
    1.33 +        continue;
    1.34 +    }
    1.35 +
    1.36 +    if (nwords > 6) {
    1.37 +      // prelink altered mapfile when the program is running.
    1.38 +      // Entries like one below have to be skipped
    1.39 +      //  /lib64/libc-2.15.so (deleted)
    1.40 +      // SO name in entries like one below have to be stripped.
    1.41 +      //  /lib64/libpthread-2.15.so.#prelink#.EECVts
    1.42 +      char *s = strstr(word[5],".#prelink#");
    1.43 +      if (s == NULL) {
    1.44 +        // No prelink keyword. skip deleted library
    1.45 +        print_debug("skip shared object %s deleted by prelink\n", word[5]);
    1.46 +        continue;
    1.47 +      }
    1.48 +
    1.49 +      // Fall through
    1.50 +      print_debug("rectifying shared object name %s changed by prelink\n", word[5]);
    1.51 +      *s = 0;
    1.52 +    }
    1.53 +
    1.54 +    if (find_lib(ph, word[5]) == false) {
    1.55         intptr_t base;
    1.56         lib_info* lib;
    1.57  #ifdef _LP64

mercurial