{"action":"created","comment":{"url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/comments/221909448","pull_request_review_id":160668926,"id":221909448,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMTkwOTQ0OA==","diff_hunk":"@@ -196,7 +196,18 @@ SvecType *classify_document(char **features, int num_features, char **document,\n #endif\n \t\t(void) hdestroy();\n \t\tordinals    = (int *)malloc(sizeof(int)*num_features); //Need to use malloc so that hdestroy() can be called.\n+\t\tif (!ordinals)\n+\t\t\tereport(ERROR,\n+\t\t\t\t\t(errcode(ERRCODE_OUT_OF_MEMORY),\n+\t\t\t\t\t errmsg(\"out of memory\")));\n+\n \t\thistogram = (float8 *)malloc(sizeof(float8)*num_features); //Use malloc because pallocs are cleaned up between queries\n+\t\tif (!histogram) {","path":"gpcontrib/gp_sparse_vector/gp_sfv.c","position":10,"original_position":10,"commit_id":"de8a1534a60d5fc294ceb01d02eec5cdded407d0","original_commit_id":"de8a1534a60d5fc294ceb01d02eec5cdded407d0","user":{"login":"hlinnaka","id":191602,"node_id":"MDQ6VXNlcjE5MTYwMg==","avatar_url":"https://avatars2.githubusercontent.com/u/191602?v=4","gravatar_id":"","url":"https://api.github.com/users/hlinnaka","html_url":"https://github.com/hlinnaka","followers_url":"https://api.github.com/users/hlinnaka/followers","following_url":"https://api.github.com/users/hlinnaka/following{/other_user}","gists_url":"https://api.github.com/users/hlinnaka/gists{/gist_id}","starred_url":"https://api.github.com/users/hlinnaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hlinnaka/subscriptions","organizations_url":"https://api.github.com/users/hlinnaka/orgs","repos_url":"https://api.github.com/users/hlinnaka/repos","events_url":"https://api.github.com/users/hlinnaka/events{/privacy}","received_events_url":"https://api.github.com/users/hlinnaka/received_events","type":"User","site_admin":false},"body":"I doubt there's really any benefit in keeping the 'histogram' array around across calls. I suggest just palloc0'ing it on every call.","created_at":"2018-10-02T11:10:59Z","updated_at":"2018-10-02T11:10:59Z","html_url":"https://github.com/greenplum-db/gpdb/pull/5903#discussion_r221909448","pull_request_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/5903","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/comments/221909448"},"html":{"href":"https://github.com/greenplum-db/gpdb/pull/5903#discussion_r221909448"},"pull_request":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/5903"}}},"pull_request":{"url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/5903","id":219640378,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE5NjQwMzc4","html_url":"https://github.com/greenplum-db/gpdb/pull/5903","diff_url":"https://github.com/greenplum-db/gpdb/pull/5903.diff","patch_url":"https://github.com/greenplum-db/gpdb/pull/5903.patch","issue_url":"https://api.github.com/repos/greenplum-db/gpdb/issues/5903","number":5903,"state":"open","locked":false,"title":"Fix memory management in gp_sparse_vector","user":{"login":"danielgustafsson","id":321790,"node_id":"MDQ6VXNlcjMyMTc5MA==","avatar_url":"https://avatars2.githubusercontent.com/u/321790?v=4","gravatar_id":"","url":"https://api.github.com/users/danielgustafsson","html_url":"https://github.com/danielgustafsson","followers_url":"https://api.github.com/users/danielgustafsson/followers","following_url":"https://api.github.com/users/danielgustafsson/following{/other_user}","gists_url":"https://api.github.com/users/danielgustafsson/gists{/gist_id}","starred_url":"https://api.github.com/users/danielgustafsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielgustafsson/subscriptions","organizations_url":"https://api.github.com/users/danielgustafsson/orgs","repos_url":"https://api.github.com/users/danielgustafsson/repos","events_url":"https://api.github.com/users/danielgustafsson/events{/privacy}","received_events_url":"https://api.github.com/users/danielgustafsson/received_events","type":"User","site_admin":false},"body":"`palloc()` is guaranteed to only return on successful allocation, so there is no need to check it. `ereport(ERROR..)` is guaranteed never to return, and to clean up on it's way out, so `pfree()`ing after an `ereport()` is not just unreachable code, it would be a double-free if it was reached.\r\n\r\nAlso add proper checks on the `malloc()` calls as those are subject to the usual memory pressure controls by the programmer.\r\n\r\nThis still leaks the `histogram` allocation but that's no worse than before.","created_at":"2018-10-02T09:33:14Z","updated_at":"2018-10-02T11:10:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0994dbb32e9cb2ab9db8b1c0e223df617c53f8c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/5903/commits","review_comments_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/5903/comments","review_comment_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/greenplum-db/gpdb/issues/5903/comments","statuses_url":"https://api.github.com/repos/greenplum-db/gpdb/statuses/de8a1534a60d5fc294ceb01d02eec5cdded407d0","head":{"label":"danielgustafsson:sparsedata_memory","ref":"sparsedata_memory","sha":"de8a1534a60d5fc294ceb01d02eec5cdded407d0","user":{"login":"danielgustafsson","id":321790,"node_id":"MDQ6VXNlcjMyMTc5MA==","avatar_url":"https://avatars2.githubusercontent.com/u/321790?v=4","gravatar_id":"","url":"https://api.github.com/users/danielgustafsson","html_url":"https://github.com/danielgustafsson","followers_url":"https://api.github.com/users/danielgustafsson/followers","following_url":"https://api.github.com/users/danielgustafsson/following{/other_user}","gists_url":"https://api.github.com/users/danielgustafsson/gists{/gist_id}","starred_url":"https://api.github.com/users/danielgustafsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielgustafsson/subscriptions","organizations_url":"https://api.github.com/users/danielgustafsson/orgs","repos_url":"https://api.github.com/users/danielgustafsson/repos","events_url":"https://api.github.com/users/danielgustafsson/events{/privacy}","received_events_url":"https://api.github.com/users/danielgustafsson/received_events","type":"User","site_admin":false},"repo":{"id":45419965,"node_id":"MDEwOlJlcG9zaXRvcnk0NTQxOTk2NQ==","name":"gpdb","full_name":"danielgustafsson/gpdb","private":false,"owner":{"login":"danielgustafsson","id":321790,"node_id":"MDQ6VXNlcjMyMTc5MA==","avatar_url":"https://avatars2.githubusercontent.com/u/321790?v=4","gravatar_id":"","url":"https://api.github.com/users/danielgustafsson","html_url":"https://github.com/danielgustafsson","followers_url":"https://api.github.com/users/danielgustafsson/followers","following_url":"https://api.github.com/users/danielgustafsson/following{/other_user}","gists_url":"https://api.github.com/users/danielgustafsson/gists{/gist_id}","starred_url":"https://api.github.com/users/danielgustafsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielgustafsson/subscriptions","organizations_url":"https://api.github.com/users/danielgustafsson/orgs","repos_url":"https://api.github.com/users/danielgustafsson/repos","events_url":"https://api.github.com/users/danielgustafsson/events{/privacy}","received_events_url":"https://api.github.com/users/danielgustafsson/received_events","type":"User","site_admin":false},"html_url":"https://github.com/danielgustafsson/gpdb","description":"Pivotal Greenplum Database","fork":true,"url":"https://api.github.com/repos/danielgustafsson/gpdb","forks_url":"https://api.github.com/repos/danielgustafsson/gpdb/forks","keys_url":"https://api.github.com/repos/danielgustafsson/gpdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danielgustafsson/gpdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danielgustafsson/gpdb/teams","hooks_url":"https://api.github.com/repos/danielgustafsson/gpdb/hooks","issue_events_url":"https://api.github.com/repos/danielgustafsson/gpdb/issues/events{/number}","events_url":"https://api.github.com/repos/danielgustafsson/gpdb/events","assignees_url":"https://api.github.com/repos/danielgustafsson/gpdb/assignees{/user}","branches_url":"https://api.github.com/repos/danielgustafsson/gpdb/branches{/branch}","tags_url":"https://api.github.com/repos/danielgustafsson/gpdb/tags","blobs_url":"https://api.github.com/repos/danielgustafsson/gpdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danielgustafsson/gpdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danielgustafsson/gpdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/danielgustafsson/gpdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danielgustafsson/gpdb/statuses/{sha}","languages_url":"https://api.github.com/repos/danielgustafsson/gpdb/languages","stargazers_url":"https://api.github.com/repos/danielgustafsson/gpdb/stargazers","contributors_url":"https://api.github.com/repos/danielgustafsson/gpdb/contributors","subscribers_url":"https://api.github.com/repos/danielgustafsson/gpdb/subscribers","subscription_url":"https://api.github.com/repos/danielgustafsson/gpdb/subscription","commits_url":"https://api.github.com/repos/danielgustafsson/gpdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/danielgustafsson/gpdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/danielgustafsson/gpdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/danielgustafsson/gpdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/danielgustafsson/gpdb/contents/{+path}","compare_url":"https://api.github.com/repos/danielgustafsson/gpdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danielgustafsson/gpdb/merges","archive_url":"https://api.github.com/repos/danielgustafsson/gpdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danielgustafsson/gpdb/downloads","issues_url":"https://api.github.com/repos/danielgustafsson/gpdb/issues{/number}","pulls_url":"https://api.github.com/repos/danielgustafsson/gpdb/pulls{/number}","milestones_url":"https://api.github.com/repos/danielgustafsson/gpdb/milestones{/number}","notifications_url":"https://api.github.com/repos/danielgustafsson/gpdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danielgustafsson/gpdb/labels{/name}","releases_url":"https://api.github.com/repos/danielgustafsson/gpdb/releases{/id}","deployments_url":"https://api.github.com/repos/danielgustafsson/gpdb/deployments","created_at":"2015-11-02T20:26:32Z","updated_at":"2017-09-11T18:30:04Z","pushed_at":"2018-10-02T11:10:15Z","git_url":"git://github.com/danielgustafsson/gpdb.git","ssh_url":"git@github.com:danielgustafsson/gpdb.git","clone_url":"https://github.com/danielgustafsson/gpdb.git","svn_url":"https://github.com/danielgustafsson/gpdb","homepage":"http://greenplum.org","size":503035,"stargazers_count":0,"watchers_count":0,"language":"PLpgSQL","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"greenplum-db:master","ref":"master","sha":"9d41f886aa38365d162667fc491daca137127fca","user":{"login":"greenplum-db","id":14097842,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MDk3ODQy","avatar_url":"https://avatars2.githubusercontent.com/u/14097842?v=4","gravatar_id":"","url":"https://api.github.com/users/greenplum-db","html_url":"https://github.com/greenplum-db","followers_url":"https://api.github.com/users/greenplum-db/followers","following_url":"https://api.github.com/users/greenplum-db/following{/other_user}","gists_url":"https://api.github.com/users/greenplum-db/gists{/gist_id}","starred_url":"https://api.github.com/users/greenplum-db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greenplum-db/subscriptions","organizations_url":"https://api.github.com/users/greenplum-db/orgs","repos_url":"https://api.github.com/users/greenplum-db/repos","events_url":"https://api.github.com/users/greenplum-db/events{/privacy}","received_events_url":"https://api.github.com/users/greenplum-db/received_events","type":"Organization","site_admin":false},"repo":{"id":44781140,"node_id":"MDEwOlJlcG9zaXRvcnk0NDc4MTE0MA==","name":"gpdb","full_name":"greenplum-db/gpdb","private":false,"owner":{"login":"greenplum-db","id":14097842,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MDk3ODQy","avatar_url":"https://avatars2.githubusercontent.com/u/14097842?v=4","gravatar_id":"","url":"https://api.github.com/users/greenplum-db","html_url":"https://github.com/greenplum-db","followers_url":"https://api.github.com/users/greenplum-db/followers","following_url":"https://api.github.com/users/greenplum-db/following{/other_user}","gists_url":"https://api.github.com/users/greenplum-db/gists{/gist_id}","starred_url":"https://api.github.com/users/greenplum-db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greenplum-db/subscriptions","organizations_url":"https://api.github.com/users/greenplum-db/orgs","repos_url":"https://api.github.com/users/greenplum-db/repos","events_url":"https://api.github.com/users/greenplum-db/events{/privacy}","received_events_url":"https://api.github.com/users/greenplum-db/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/greenplum-db/gpdb","description":"Greenplum Database","fork":false,"url":"https://api.github.com/repos/greenplum-db/gpdb","forks_url":"https://api.github.com/repos/greenplum-db/gpdb/forks","keys_url":"https://api.github.com/repos/greenplum-db/gpdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/greenplum-db/gpdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/greenplum-db/gpdb/teams","hooks_url":"https://api.github.com/repos/greenplum-db/gpdb/hooks","issue_events_url":"https://api.github.com/repos/greenplum-db/gpdb/issues/events{/number}","events_url":"https://api.github.com/repos/greenplum-db/gpdb/events","assignees_url":"https://api.github.com/repos/greenplum-db/gpdb/assignees{/user}","branches_url":"https://api.github.com/repos/greenplum-db/gpdb/branches{/branch}","tags_url":"https://api.github.com/repos/greenplum-db/gpdb/tags","blobs_url":"https://api.github.com/repos/greenplum-db/gpdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/greenplum-db/gpdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/greenplum-db/gpdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/greenplum-db/gpdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/greenplum-db/gpdb/statuses/{sha}","languages_url":"https://api.github.com/repos/greenplum-db/gpdb/languages","stargazers_url":"https://api.github.com/repos/greenplum-db/gpdb/stargazers","contributors_url":"https://api.github.com/repos/greenplum-db/gpdb/contributors","subscribers_url":"https://api.github.com/repos/greenplum-db/gpdb/subscribers","subscription_url":"https://api.github.com/repos/greenplum-db/gpdb/subscription","commits_url":"https://api.github.com/repos/greenplum-db/gpdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/greenplum-db/gpdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/greenplum-db/gpdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/greenplum-db/gpdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/greenplum-db/gpdb/contents/{+path}","compare_url":"https://api.github.com/repos/greenplum-db/gpdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/greenplum-db/gpdb/merges","archive_url":"https://api.github.com/repos/greenplum-db/gpdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/greenplum-db/gpdb/downloads","issues_url":"https://api.github.com/repos/greenplum-db/gpdb/issues{/number}","pulls_url":"https://api.github.com/repos/greenplum-db/gpdb/pulls{/number}","milestones_url":"https://api.github.com/repos/greenplum-db/gpdb/milestones{/number}","notifications_url":"https://api.github.com/repos/greenplum-db/gpdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/greenplum-db/gpdb/labels{/name}","releases_url":"https://api.github.com/repos/greenplum-db/gpdb/releases{/id}","deployments_url":"https://api.github.com/repos/greenplum-db/gpdb/deployments","created_at":"2015-10-23T00:25:17Z","updated_at":"2018-10-02T10:41:17Z","pushed_at":"2018-10-02T10:14:11Z","git_url":"git://github.com/greenplum-db/gpdb.git","ssh_url":"git@github.com:greenplum-db/gpdb.git","clone_url":"https://github.com/greenplum-db/gpdb.git","svn_url":"https://github.com/greenplum-db/gpdb","homepage":"http://greenplum.org","size":309820,"stargazers_count":2727,"watchers_count":2727,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":825,"mirror_url":null,"archived":false,"open_issues_count":229,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":825,"open_issues":229,"watchers":2727,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/5903"},"html":{"href":"https://github.com/greenplum-db/gpdb/pull/5903"},"issue":{"href":"https://api.github.com/repos/greenplum-db/gpdb/issues/5903"},"comments":{"href":"https://api.github.com/repos/greenplum-db/gpdb/issues/5903/comments"},"review_comments":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/5903/comments"},"review_comment":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/greenplum-db/gpdb/pulls/5903/commits"},"statuses":{"href":"https://api.github.com/repos/greenplum-db/gpdb/statuses/de8a1534a60d5fc294ceb01d02eec5cdded407d0"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"hlinnaka"}}