{"action":"created","issue":{"url":"https://api.github.com/repos/gperftools/gperftools/issues/601","repository_url":"https://api.github.com/repos/gperftools/gperftools","labels_url":"https://api.github.com/repos/gperftools/gperftools/issues/601/labels{/name}","comments_url":"https://api.github.com/repos/gperftools/gperftools/issues/601/comments","events_url":"https://api.github.com/repos/gperftools/gperftools/issues/601/events","html_url":"https://github.com/gperftools/gperftools/issues/601","id":102614533,"number":601,"title":"profile filename doesn't include pid if child doesn't call exec()","user":{"login":"alk","id":14850,"avatar_url":"https://avatars.githubusercontent.com/u/14850?v=3","gravatar_id":"","url":"https://api.github.com/users/alk","html_url":"https://github.com/alk","followers_url":"https://api.github.com/users/alk/followers","following_url":"https://api.github.com/users/alk/following{/other_user}","gists_url":"https://api.github.com/users/alk/gists{/gist_id}","starred_url":"https://api.github.com/users/alk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alk/subscriptions","organizations_url":"https://api.github.com/users/alk/orgs","repos_url":"https://api.github.com/users/alk/repos","events_url":"https://api.github.com/users/alk/events{/privacy}","received_events_url":"https://api.github.com/users/alk/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/gperftools/gperftools/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"},{"url":"https://api.github.com/repos/gperftools/gperftools/labels/Status-New","name":"Status-New","color":"ededed"},{"url":"https://api.github.com/repos/gperftools/gperftools/labels/Type-Defect","name":"Type-Defect","color":"ededed"}],"state":"open","locked":false,"assignee":{"login":"alk","id":14850,"avatar_url":"https://avatars.githubusercontent.com/u/14850?v=3","gravatar_id":"","url":"https://api.github.com/users/alk","html_url":"https://github.com/alk","followers_url":"https://api.github.com/users/alk/followers","following_url":"https://api.github.com/users/alk/following{/other_user}","gists_url":"https://api.github.com/users/alk/gists{/gist_id}","starred_url":"https://api.github.com/users/alk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alk/subscriptions","organizations_url":"https://api.github.com/users/alk/orgs","repos_url":"https://api.github.com/users/alk/repos","events_url":"https://api.github.com/users/alk/events{/privacy}","received_events_url":"https://api.github.com/users/alk/received_events","type":"User","site_admin":false},"assignees":[{"login":"alk","id":14850,"avatar_url":"https://avatars.githubusercontent.com/u/14850?v=3","gravatar_id":"","url":"https://api.github.com/users/alk","html_url":"https://github.com/alk","followers_url":"https://api.github.com/users/alk/followers","following_url":"https://api.github.com/users/alk/following{/other_user}","gists_url":"https://api.github.com/users/alk/gists{/gist_id}","starred_url":"https://api.github.com/users/alk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alk/subscriptions","organizations_url":"https://api.github.com/users/alk/orgs","repos_url":"https://api.github.com/users/alk/repos","events_url":"https://api.github.com/users/alk/events{/privacy}","received_events_url":"https://api.github.com/users/alk/received_events","type":"User","site_admin":false}],"milestone":null,"comments":6,"created_at":"2015-08-23T12:33:20Z","updated_at":"2016-06-26T02:40:32Z","closed_at":null,"body":"Originally reported on Google Code with ID 598\n```\nWhat steps will reproduce the problem?\nOur application has a parent process that forks several children, but some of these\nchildren don't call exec().\r\n\r\nWhat is the expected output? What do you see instead?\nWhen the application exits, the children that didn't call exec all get dumped to the\nsame file overwriting each other:\r\n\r\nDumping heap profile to normal.0001.heap (Exiting)\r\nDumping heap profile to normal.0001.heap (Exiting)\r\nDumping heap profile to normal.0001.heap (Exiting)\r\n\r\nWhat version of the product are you using? On what operating system?\n2.1 on linux.\r\n\r\nPlease provide any additional information below.\n\r\nThe problem is that GetUniquePathFromEnv() doesn't seem to be called if the child process\ndoesn't call exec().  So why not just always include the pid in the filename?   This\npatch works for me:\r\n\r\n--- gperftools-2.1.orig/src/base/sysinfo.cc     2013-07-30 10:12:11.000000000 +0100\r\n+++ gperftools-2.1/src/base/sysinfo.cc  2014-01-13 17:42:53.634101186 +0000\r\n@@ -192,13 +192,7 @@\r\n   char* envval = getenv(env_name);\r\n   if (envval == NULL || *envval == '\\0')\r\n     return false;\r\n-  if (envval[0] & 128) {                  // high bit is set\r\n-    snprintf(path, PATH_MAX, \"%c%s_%u\",   // add pid and clear high bit\r\n-             envval[0] & 127, envval+1, (unsigned int)(getpid()));\r\n-  } else {\r\n     snprintf(path, PATH_MAX, \"%s\", envval);\r\n-    envval[0] |= 128;                     // set high bit for kids to see\r\n-  }\r\n   return true;\r\n }\r\n \r\ndiff -wur gperftools-2.1.orig/src/heap-profiler.cc gperftools-2.1/src/heap-profiler.cc\r\n--- gperftools-2.1.orig/src/heap-profiler.cc    2013-07-30 10:12:11.000000000 +0100\r\n+++ gperftools-2.1/src/heap-profiler.cc 2014-01-14 12:40:14.886714613 +0000\r\n@@ -228,8 +228,8 @@\r\n   // Make file name\r\n   char file_name[1000];\r\n   dump_count++;\r\n-  snprintf(file_name, sizeof(file_name), \"%s.%04d%s\",\r\n-           filename_prefix, dump_count, HeapProfileTable::kFileExt);\r\n+  snprintf(file_name, sizeof(file_name), \"%s_%u.%04d%s\",\r\n+           filename_prefix, (unsigned int)getpid(), dump_count, HeapProfileTable::kFileExt);\r\n \r\n   // Dump the profile\r\n   RAW_VLOG(0, \"Dumping heap profile to %s (%s)\", file_name, reason);\r\n\r\n\r\n\r\nThat gives the following output:\r\n\r\nDumping heap profile to normal_7880.0001.heap (Exiting)\r\nDumping heap profile to normal_7879.0001.heap (Exiting)\r\nDumping heap profile to normal_7874.0001.heap (Exiting)\r\n\r\n\r\nAlternatively pthread_atfork could be used? \n```\n\nReported by `ldarby@brocade.com` on 2014-01-14 12:47:57\n"},"comment":{"url":"https://api.github.com/repos/gperftools/gperftools/issues/comments/228581054","html_url":"https://github.com/gperftools/gperftools/issues/601#issuecomment-228581054","issue_url":"https://api.github.com/repos/gperftools/gperftools/issues/601","id":228581054,"user":{"login":"alk","id":14850,"avatar_url":"https://avatars.githubusercontent.com/u/14850?v=3","gravatar_id":"","url":"https://api.github.com/users/alk","html_url":"https://github.com/alk","followers_url":"https://api.github.com/users/alk/followers","following_url":"https://api.github.com/users/alk/following{/other_user}","gists_url":"https://api.github.com/users/alk/gists{/gist_id}","starred_url":"https://api.github.com/users/alk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alk/subscriptions","organizations_url":"https://api.github.com/users/alk/orgs","repos_url":"https://api.github.com/users/alk/repos","events_url":"https://api.github.com/users/alk/events{/privacy}","received_events_url":"https://api.github.com/users/alk/received_events","type":"User","site_admin":false},"created_at":"2016-06-26T02:40:32Z","updated_at":"2016-06-26T02:40:32Z","body":"The concern with always appending pid is it might break some folk's scripts."}}
{"actor":{"display_login":"alk"}}