Machines with long hostnames not running pcp PM daemon can have the linux-pcp exit preventing anything from using papi

Issue #124 resolved
Will Cohen created an issue

I was trying to run tests on one of a Red Hat test machine that has a long hostname, ampere-mtsnow-altramax-01-vm-25.lab.eng.rdu2.redhat.com. I was suprized when running any of the tests I got the following:

./ctests/first
components/pcp/linux-pcp.c:892 unexpected string function error.

I can see that the combination of the message and the hostname exceed the PAPI_MAX_STR_LEN in the code from src/componenst/pcp/linux-pcp.c:887 :

   ctxHandle = pcp_pmNewContext(PM_CONTEXT_HOST, "local:");             // Set the new context to local host.
   if (ctxHandle < 0) {
      int strErr=snprintf(reason, rLen, "Cannot connect to PM Daemon on host \"%s\".\n "
         "(Ensure this machine has Performance Co-Pilot installed.)\n", hostname);
      reason[rLen-1]=0;
      if (strErr > rLen) HANDLE_STRING_ERROR;
      retval = PAPI_ESYS;
      goto fn_fail;
   }

Exiting when the error string is truncated might not be the best way to handle this issue which is what HANDLE_STRING_ERROR currently does in linux-pcp:65:

#define HANDLE_STRING_ERROR {fprintf(stderr,"%s:%i unexpected string function error.\n",__FILE__,__LINE__); exit(-1);}

Comments (3)

  1. Log in to comment