{"action":"opened","number":42,"pull_request":{"url":"https://api.github.com/repos/performancecopilot/pcp/pulls/42","id":42989481,"html_url":"https://github.com/performancecopilot/pcp/pull/42","diff_url":"https://github.com/performancecopilot/pcp/pull/42.diff","patch_url":"https://github.com/performancecopilot/pcp/pull/42.patch","issue_url":"https://api.github.com/repos/performancecopilot/pcp/issues/42","number":42,"state":"open","locked":false,"title":"mingw64: Python pmapi on Windows - prevent crash when free()'ing resources","user":{"login":"dgiagio","id":124647,"avatar_url":"https://avatars.githubusercontent.com/u/124647?v=3","gravatar_id":"","url":"https://api.github.com/users/dgiagio","html_url":"https://github.com/dgiagio","followers_url":"https://api.github.com/users/dgiagio/followers","following_url":"https://api.github.com/users/dgiagio/following{/other_user}","gists_url":"https://api.github.com/users/dgiagio/gists{/gist_id}","starred_url":"https://api.github.com/users/dgiagio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgiagio/subscriptions","organizations_url":"https://api.github.com/users/dgiagio/orgs","repos_url":"https://api.github.com/users/dgiagio/repos","events_url":"https://api.github.com/users/dgiagio/events{/privacy}","received_events_url":"https://api.github.com/users/dgiagio/received_events","type":"User","site_admin":false},"body":"When calling Python pmapi functions such as ```pmGetChildren```, ```pmGetInDom```, etc. these functions internally allocate resources using ```malloc```. Unfortunately the current code on Windows crashes when ```free```'ing these resources because the ```free``` function used doesn't always belong to the correct ```msvcrt.dll``` version.\r\n\r\nAFAIK artifacts (.exe's, .dll's, etc) compiled using mingw64 are always linked with ```\\Windows\\System32\\msvcrt.dll```, but Python is not necessarily. E.g:\r\n\r\n```\r\nC:\\>\\Python27\\python\r\nPython 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> from ctypes import CDLL\r\n>>> from ctypes.util import find_library\r\n>>> LIBC_OK = CDLL(find_library(\"msvcrt\"))\r\n>>> LIBC_ERR = CDLL(find_library(\"c\"))\r\n>>> LIBC_OK\r\n<CDLL 'C:\\Windows\\system32\\msvcrt.dll', handle cdc40000 at 1db5e80>\r\n>>> LIBC_ERR\r\n<CDLL 'msvcr90.dll', handle 65a70000 at 1e61d68>\r\n>>>\r\n```\r\nThat means that ```libpcp.dll``` (used by pmapi Python module) is using the ```malloc``` function from ```msvcrt.dll``` while Python is using the ```free``` function from ```msvcrt90.dll``` and thus it crashes.\r\n\r\nThis fix ensures that if we're on Windows platform, we always use ```msvcrt.dll```. On other platforms it's unchanged and keeps using the platform's libc.","created_at":"2015-08-20T23:19:10Z","updated_at":"2015-08-20T23:19:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/performancecopilot/pcp/pulls/42/commits","review_comments_url":"https://api.github.com/repos/performancecopilot/pcp/pulls/42/comments","review_comment_url":"https://api.github.com/repos/performancecopilot/pcp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/performancecopilot/pcp/issues/42/comments","statuses_url":"https://api.github.com/repos/performancecopilot/pcp/statuses/b1b7f181761dd160635650e7a93f5c26090a1723","head":{"label":"dgiagio:windows_pmapi_msvcrt","ref":"windows_pmapi_msvcrt","sha":"b1b7f181761dd160635650e7a93f5c26090a1723","user":{"login":"dgiagio","id":124647,"avatar_url":"https://avatars.githubusercontent.com/u/124647?v=3","gravatar_id":"","url":"https://api.github.com/users/dgiagio","html_url":"https://github.com/dgiagio","followers_url":"https://api.github.com/users/dgiagio/followers","following_url":"https://api.github.com/users/dgiagio/following{/other_user}","gists_url":"https://api.github.com/users/dgiagio/gists{/gist_id}","starred_url":"https://api.github.com/users/dgiagio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgiagio/subscriptions","organizations_url":"https://api.github.com/users/dgiagio/orgs","repos_url":"https://api.github.com/users/dgiagio/repos","events_url":"https://api.github.com/users/dgiagio/events{/privacy}","received_events_url":"https://api.github.com/users/dgiagio/received_events","type":"User","site_admin":false},"repo":{"id":41118146,"name":"pcp","full_name":"dgiagio/pcp","owner":{"login":"dgiagio","id":124647,"avatar_url":"https://avatars.githubusercontent.com/u/124647?v=3","gravatar_id":"","url":"https://api.github.com/users/dgiagio","html_url":"https://github.com/dgiagio","followers_url":"https://api.github.com/users/dgiagio/followers","following_url":"https://api.github.com/users/dgiagio/following{/other_user}","gists_url":"https://api.github.com/users/dgiagio/gists{/gist_id}","starred_url":"https://api.github.com/users/dgiagio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgiagio/subscriptions","organizations_url":"https://api.github.com/users/dgiagio/orgs","repos_url":"https://api.github.com/users/dgiagio/repos","events_url":"https://api.github.com/users/dgiagio/events{/privacy}","received_events_url":"https://api.github.com/users/dgiagio/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dgiagio/pcp","description":"Performance Co-Pilot","fork":true,"url":"https://api.github.com/repos/dgiagio/pcp","forks_url":"https://api.github.com/repos/dgiagio/pcp/forks","keys_url":"https://api.github.com/repos/dgiagio/pcp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dgiagio/pcp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dgiagio/pcp/teams","hooks_url":"https://api.github.com/repos/dgiagio/pcp/hooks","issue_events_url":"https://api.github.com/repos/dgiagio/pcp/issues/events{/number}","events_url":"https://api.github.com/repos/dgiagio/pcp/events","assignees_url":"https://api.github.com/repos/dgiagio/pcp/assignees{/user}","branches_url":"https://api.github.com/repos/dgiagio/pcp/branches{/branch}","tags_url":"https://api.github.com/repos/dgiagio/pcp/tags","blobs_url":"https://api.github.com/repos/dgiagio/pcp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dgiagio/pcp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dgiagio/pcp/git/refs{/sha}","trees_url":"https://api.github.com/repos/dgiagio/pcp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dgiagio/pcp/statuses/{sha}","languages_url":"https://api.github.com/repos/dgiagio/pcp/languages","stargazers_url":"https://api.github.com/repos/dgiagio/pcp/stargazers","contributors_url":"https://api.github.com/repos/dgiagio/pcp/contributors","subscribers_url":"https://api.github.com/repos/dgiagio/pcp/subscribers","subscription_url":"https://api.github.com/repos/dgiagio/pcp/subscription","commits_url":"https://api.github.com/repos/dgiagio/pcp/commits{/sha}","git_commits_url":"https://api.github.com/repos/dgiagio/pcp/git/commits{/sha}","comments_url":"https://api.github.com/repos/dgiagio/pcp/comments{/number}","issue_comment_url":"https://api.github.com/repos/dgiagio/pcp/issues/comments{/number}","contents_url":"https://api.github.com/repos/dgiagio/pcp/contents/{+path}","compare_url":"https://api.github.com/repos/dgiagio/pcp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dgiagio/pcp/merges","archive_url":"https://api.github.com/repos/dgiagio/pcp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dgiagio/pcp/downloads","issues_url":"https://api.github.com/repos/dgiagio/pcp/issues{/number}","pulls_url":"https://api.github.com/repos/dgiagio/pcp/pulls{/number}","milestones_url":"https://api.github.com/repos/dgiagio/pcp/milestones{/number}","notifications_url":"https://api.github.com/repos/dgiagio/pcp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dgiagio/pcp/labels{/name}","releases_url":"https://api.github.com/repos/dgiagio/pcp/releases{/id}","created_at":"2015-08-20T20:47:35Z","updated_at":"2015-08-20T20:47:50Z","pushed_at":"2015-08-20T20:50:50Z","git_url":"git://github.com/dgiagio/pcp.git","ssh_url":"git@github.com:dgiagio/pcp.git","clone_url":"https://github.com/dgiagio/pcp.git","svn_url":"https://github.com/dgiagio/pcp","homepage":null,"size":66791,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"performancecopilot:master","ref":"master","sha":"aec2f0b6a46f6e94cbb47051ed53d247e7cd9f8d","user":{"login":"performancecopilot","id":8467970,"avatar_url":"https://avatars.githubusercontent.com/u/8467970?v=3","gravatar_id":"","url":"https://api.github.com/users/performancecopilot","html_url":"https://github.com/performancecopilot","followers_url":"https://api.github.com/users/performancecopilot/followers","following_url":"https://api.github.com/users/performancecopilot/following{/other_user}","gists_url":"https://api.github.com/users/performancecopilot/gists{/gist_id}","starred_url":"https://api.github.com/users/performancecopilot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/performancecopilot/subscriptions","organizations_url":"https://api.github.com/users/performancecopilot/orgs","repos_url":"https://api.github.com/users/performancecopilot/repos","events_url":"https://api.github.com/users/performancecopilot/events{/privacy}","received_events_url":"https://api.github.com/users/performancecopilot/received_events","type":"Organization","site_admin":false},"repo":{"id":23028937,"name":"pcp","full_name":"performancecopilot/pcp","owner":{"login":"performancecopilot","id":8467970,"avatar_url":"https://avatars.githubusercontent.com/u/8467970?v=3","gravatar_id":"","url":"https://api.github.com/users/performancecopilot","html_url":"https://github.com/performancecopilot","followers_url":"https://api.github.com/users/performancecopilot/followers","following_url":"https://api.github.com/users/performancecopilot/following{/other_user}","gists_url":"https://api.github.com/users/performancecopilot/gists{/gist_id}","starred_url":"https://api.github.com/users/performancecopilot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/performancecopilot/subscriptions","organizations_url":"https://api.github.com/users/performancecopilot/orgs","repos_url":"https://api.github.com/users/performancecopilot/repos","events_url":"https://api.github.com/users/performancecopilot/events{/privacy}","received_events_url":"https://api.github.com/users/performancecopilot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/performancecopilot/pcp","description":"Performance Co-Pilot","fork":false,"url":"https://api.github.com/repos/performancecopilot/pcp","forks_url":"https://api.github.com/repos/performancecopilot/pcp/forks","keys_url":"https://api.github.com/repos/performancecopilot/pcp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/performancecopilot/pcp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/performancecopilot/pcp/teams","hooks_url":"https://api.github.com/repos/performancecopilot/pcp/hooks","issue_events_url":"https://api.github.com/repos/performancecopilot/pcp/issues/events{/number}","events_url":"https://api.github.com/repos/performancecopilot/pcp/events","assignees_url":"https://api.github.com/repos/performancecopilot/pcp/assignees{/user}","branches_url":"https://api.github.com/repos/performancecopilot/pcp/branches{/branch}","tags_url":"https://api.github.com/repos/performancecopilot/pcp/tags","blobs_url":"https://api.github.com/repos/performancecopilot/pcp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/performancecopilot/pcp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/performancecopilot/pcp/git/refs{/sha}","trees_url":"https://api.github.com/repos/performancecopilot/pcp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/performancecopilot/pcp/statuses/{sha}","languages_url":"https://api.github.com/repos/performancecopilot/pcp/languages","stargazers_url":"https://api.github.com/repos/performancecopilot/pcp/stargazers","contributors_url":"https://api.github.com/repos/performancecopilot/pcp/contributors","subscribers_url":"https://api.github.com/repos/performancecopilot/pcp/subscribers","subscription_url":"https://api.github.com/repos/performancecopilot/pcp/subscription","commits_url":"https://api.github.com/repos/performancecopilot/pcp/commits{/sha}","git_commits_url":"https://api.github.com/repos/performancecopilot/pcp/git/commits{/sha}","comments_url":"https://api.github.com/repos/performancecopilot/pcp/comments{/number}","issue_comment_url":"https://api.github.com/repos/performancecopilot/pcp/issues/comments{/number}","contents_url":"https://api.github.com/repos/performancecopilot/pcp/contents/{+path}","compare_url":"https://api.github.com/repos/performancecopilot/pcp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/performancecopilot/pcp/merges","archive_url":"https://api.github.com/repos/performancecopilot/pcp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/performancecopilot/pcp/downloads","issues_url":"https://api.github.com/repos/performancecopilot/pcp/issues{/number}","pulls_url":"https://api.github.com/repos/performancecopilot/pcp/pulls{/number}","milestones_url":"https://api.github.com/repos/performancecopilot/pcp/milestones{/number}","notifications_url":"https://api.github.com/repos/performancecopilot/pcp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/performancecopilot/pcp/labels{/name}","releases_url":"https://api.github.com/repos/performancecopilot/pcp/releases{/id}","created_at":"2014-08-16T23:06:22Z","updated_at":"2015-08-20T01:20:43Z","pushed_at":"2015-08-20T23:19:11Z","git_url":"git://github.com/performancecopilot/pcp.git","ssh_url":"git@github.com:performancecopilot/pcp.git","clone_url":"https://github.com/performancecopilot/pcp.git","svn_url":"https://github.com/performancecopilot/pcp","homepage":null,"size":66791,"stargazers_count":206,"watchers_count":206,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":10,"forks":16,"open_issues":10,"watchers":206,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/performancecopilot/pcp/pulls/42"},"html":{"href":"https://github.com/performancecopilot/pcp/pull/42"},"issue":{"href":"https://api.github.com/repos/performancecopilot/pcp/issues/42"},"comments":{"href":"https://api.github.com/repos/performancecopilot/pcp/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/performancecopilot/pcp/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/performancecopilot/pcp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/performancecopilot/pcp/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/performancecopilot/pcp/statuses/b1b7f181761dd160635650e7a93f5c26090a1723"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":3,"deletions":2,"changed_files":1}}