{"action":"created","comment":{"url":"https://api.github.com/repos/awslabs/aws-c-common/pulls/comments/223098157","pull_request_review_id":162150851,"id":223098157,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMzA5ODE1Nw==","diff_hunk":"@@ -138,10 +138,10 @@ AWS_STATIC_ASSERT(sizeof(char) == 1);\n \n /* Allocator structure. An instance of this will be passed around for anything needing memory allocation */\n struct aws_allocator {\n-    void *(*mem_acquire)(struct aws_allocator *allocator, size_t size);\n+    void *(*mem_acquire)(struct aws_allocator *allocator, size_t size, const char *file, int line);","path":"include/aws/common/common.h","position":5,"original_position":5,"commit_id":"88742d746d495a7509ca2b5b111d740cc1ff51ed","original_commit_id":"88742d746d495a7509ca2b5b111d740cc1ff51ed","user":{"login":"justinboswell","id":3382222,"node_id":"MDQ6VXNlcjMzODIyMjI=","avatar_url":"https://avatars2.githubusercontent.com/u/3382222?v=4","gravatar_id":"","url":"https://api.github.com/users/justinboswell","html_url":"https://github.com/justinboswell","followers_url":"https://api.github.com/users/justinboswell/followers","following_url":"https://api.github.com/users/justinboswell/following{/other_user}","gists_url":"https://api.github.com/users/justinboswell/gists{/gist_id}","starred_url":"https://api.github.com/users/justinboswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinboswell/subscriptions","organizations_url":"https://api.github.com/users/justinboswell/orgs","repos_url":"https://api.github.com/users/justinboswell/repos","events_url":"https://api.github.com/users/justinboswell/events{/privacy}","received_events_url":"https://api.github.com/users/justinboswell/received_events","type":"User","site_admin":false},"body":"My suggestion here would be to have a structure which encapsulates file/line, and potentially future things like name/category/flags or any other distinguishing info we may come up with. You can construct the structure and pass it by value via macro. That way the API doesn't need to change should we need to collect more info, we could just add an additional macro or something to provide it.","created_at":"2018-10-05T18:19:28Z","updated_at":"2018-10-05T18:19:29Z","html_url":"https://github.com/awslabs/aws-c-common/pull/153#discussion_r223098157","pull_request_url":"https://api.github.com/repos/awslabs/aws-c-common/pulls/153","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/awslabs/aws-c-common/pulls/comments/223098157"},"html":{"href":"https://github.com/awslabs/aws-c-common/pull/153#discussion_r223098157"},"pull_request":{"href":"https://api.github.com/repos/awslabs/aws-c-common/pulls/153"}}},"pull_request":{"url":"https://api.github.com/repos/awslabs/aws-c-common/pulls/153","id":220575120,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwNTc1MTIw","html_url":"https://github.com/awslabs/aws-c-common/pull/153","diff_url":"https://github.com/awslabs/aws-c-common/pull/153.diff","patch_url":"https://github.com/awslabs/aws-c-common/pull/153.patch","issue_url":"https://api.github.com/repos/awslabs/aws-c-common/issues/153","number":153,"state":"open","locked":false,"title":"Default Allocator Leak Checker","user":{"login":"RandyGaul","id":1919825,"node_id":"MDQ6VXNlcjE5MTk4MjU=","avatar_url":"https://avatars1.githubusercontent.com/u/1919825?v=4","gravatar_id":"","url":"https://api.github.com/users/RandyGaul","html_url":"https://github.com/RandyGaul","followers_url":"https://api.github.com/users/RandyGaul/followers","following_url":"https://api.github.com/users/RandyGaul/following{/other_user}","gists_url":"https://api.github.com/users/RandyGaul/gists{/gist_id}","starred_url":"https://api.github.com/users/RandyGaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RandyGaul/subscriptions","organizations_url":"https://api.github.com/users/RandyGaul/orgs","repos_url":"https://api.github.com/users/RandyGaul/repos","events_url":"https://api.github.com/users/RandyGaul/events{/privacy}","received_events_url":"https://api.github.com/users/RandyGaul/received_events","type":"User","site_admin":false},"body":"Implemented a quick and dirty leak checker for the default allocator in aws-c-common. Useful for grabbing file/line pairs, even Apple machines (where valgrind/sanitizers can't perform leak checking).\r\n\r\nJust throwing this out here in case anyone else thinks it might be good to add to common. Otherwise it can just live in this branch, and I'll personally refer to it as needed.\r\n\r\nEverything is compiled away by default, except for two extra parameters passed to `aws_mem_acquire` and `aws_mem_realloc` (one for `const char *file` and one for `int line`). To enable the leak checking `AWS_DEFAULT_ALLOCATOR_LEAKCHECK` can be defined.\r\n\r\nThere's a function called `aws_mem_print_leaks_from_default_allocator`, which prints to `stderr` like so:\r\n\r\n```\r\nLEAKED 280 bytes from file \"/Users/randgaul/Desktop/work/aws-c-common/source/common.c\" at line 269 from address 0x6120000004e8.\r\nLEAKED 280 bytes from file \"/Users/randgaul/Desktop/work/aws-c-common/source/common.c\" at line 269 from address 0x612000000368.\r\nLEAKED 120 bytes from file \"/Users/randgaul/Desktop/work/aws-c-common/source/common.c\" at line 269 from address 0x60e000000228.\r\nLEAKED 1096 bytes from file \"/Users/randgaul/Desktop/work/aws-c-common/source/common.c\" at line 269 from address 0x6190000023a8.\r\nLEAKED 664 bytes from file \"/Users/randgaul/Desktop/work/aws-c-common/source/common.c\" at line 269 from address 0x6170000000a8.\r\nWARNING: Memory leaks detected (see above).\r\n```\r\n\r\nAnd if no leaks are there, prints somethiing like: `SUCCESS: No memory leaks detected.`\r\n\r\nI considered implementing leak checking in a way such that even user-provided allocators could use the leak printing function -- but this turned out to not really be worth mangling the allocator API. Instead, just providing this function for the default allocator was good enough for my own uses.\r\n\r\nBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.\r\n","created_at":"2018-10-05T03:18:50Z","updated_at":"2018-10-05T18:19:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"04f245f7789b8aa2726f9b3c0a2a929755e772a6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/awslabs/aws-c-common/pulls/153/commits","review_comments_url":"https://api.github.com/repos/awslabs/aws-c-common/pulls/153/comments","review_comment_url":"https://api.github.com/repos/awslabs/aws-c-common/pulls/comments{/number}","comments_url":"https://api.github.com/repos/awslabs/aws-c-common/issues/153/comments","statuses_url":"https://api.github.com/repos/awslabs/aws-c-common/statuses/88742d746d495a7509ca2b5b111d740cc1ff51ed","head":{"label":"awslabs:leak_checker","ref":"leak_checker","sha":"88742d746d495a7509ca2b5b111d740cc1ff51ed","user":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"repo":{"id":117142517,"node_id":"MDEwOlJlcG9zaXRvcnkxMTcxNDI1MTc=","name":"aws-c-common","full_name":"awslabs/aws-c-common","private":false,"owner":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/awslabs/aws-c-common","description":"Core c99 package for AWS SDK for C. Includes cross-platform primitives, configuration, data structures, and error handling.","fork":false,"url":"https://api.github.com/repos/awslabs/aws-c-common","forks_url":"https://api.github.com/repos/awslabs/aws-c-common/forks","keys_url":"https://api.github.com/repos/awslabs/aws-c-common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/awslabs/aws-c-common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/awslabs/aws-c-common/teams","hooks_url":"https://api.github.com/repos/awslabs/aws-c-common/hooks","issue_events_url":"https://api.github.com/repos/awslabs/aws-c-common/issues/events{/number}","events_url":"https://api.github.com/repos/awslabs/aws-c-common/events","assignees_url":"https://api.github.com/repos/awslabs/aws-c-common/assignees{/user}","branches_url":"https://api.github.com/repos/awslabs/aws-c-common/branches{/branch}","tags_url":"https://api.github.com/repos/awslabs/aws-c-common/tags","blobs_url":"https://api.github.com/repos/awslabs/aws-c-common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/awslabs/aws-c-common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/awslabs/aws-c-common/git/refs{/sha}","trees_url":"https://api.github.com/repos/awslabs/aws-c-common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/awslabs/aws-c-common/statuses/{sha}","languages_url":"https://api.github.com/repos/awslabs/aws-c-common/languages","stargazers_url":"https://api.github.com/repos/awslabs/aws-c-common/stargazers","contributors_url":"https://api.github.com/repos/awslabs/aws-c-common/contributors","subscribers_url":"https://api.github.com/repos/awslabs/aws-c-common/subscribers","subscription_url":"https://api.github.com/repos/awslabs/aws-c-common/subscription","commits_url":"https://api.github.com/repos/awslabs/aws-c-common/commits{/sha}","git_commits_url":"https://api.github.com/repos/awslabs/aws-c-common/git/commits{/sha}","comments_url":"https://api.github.com/repos/awslabs/aws-c-common/comments{/number}","issue_comment_url":"https://api.github.com/repos/awslabs/aws-c-common/issues/comments{/number}","contents_url":"https://api.github.com/repos/awslabs/aws-c-common/contents/{+path}","compare_url":"https://api.github.com/repos/awslabs/aws-c-common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/awslabs/aws-c-common/merges","archive_url":"https://api.github.com/repos/awslabs/aws-c-common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/awslabs/aws-c-common/downloads","issues_url":"https://api.github.com/repos/awslabs/aws-c-common/issues{/number}","pulls_url":"https://api.github.com/repos/awslabs/aws-c-common/pulls{/number}","milestones_url":"https://api.github.com/repos/awslabs/aws-c-common/milestones{/number}","notifications_url":"https://api.github.com/repos/awslabs/aws-c-common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/awslabs/aws-c-common/labels{/name}","releases_url":"https://api.github.com/repos/awslabs/aws-c-common/releases{/id}","deployments_url":"https://api.github.com/repos/awslabs/aws-c-common/deployments","created_at":"2018-01-11T19:17:12Z","updated_at":"2018-10-04T00:31:49Z","pushed_at":"2018-10-05T03:18:51Z","git_url":"git://github.com/awslabs/aws-c-common.git","ssh_url":"git@github.com:awslabs/aws-c-common.git","clone_url":"https://github.com/awslabs/aws-c-common.git","svn_url":"https://github.com/awslabs/aws-c-common","homepage":null,"size":780,"stargazers_count":34,"watchers_count":34,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":15,"open_issues":11,"watchers":34,"default_branch":"master"}},"base":{"label":"awslabs:master","ref":"master","sha":"c2803eb6034dca22277a38a7ee3fd1129e3afb4e","user":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"repo":{"id":117142517,"node_id":"MDEwOlJlcG9zaXRvcnkxMTcxNDI1MTc=","name":"aws-c-common","full_name":"awslabs/aws-c-common","private":false,"owner":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/awslabs/aws-c-common","description":"Core c99 package for AWS SDK for C. Includes cross-platform primitives, configuration, data structures, and error handling.","fork":false,"url":"https://api.github.com/repos/awslabs/aws-c-common","forks_url":"https://api.github.com/repos/awslabs/aws-c-common/forks","keys_url":"https://api.github.com/repos/awslabs/aws-c-common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/awslabs/aws-c-common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/awslabs/aws-c-common/teams","hooks_url":"https://api.github.com/repos/awslabs/aws-c-common/hooks","issue_events_url":"https://api.github.com/repos/awslabs/aws-c-common/issues/events{/number}","events_url":"https://api.github.com/repos/awslabs/aws-c-common/events","assignees_url":"https://api.github.com/repos/awslabs/aws-c-common/assignees{/user}","branches_url":"https://api.github.com/repos/awslabs/aws-c-common/branches{/branch}","tags_url":"https://api.github.com/repos/awslabs/aws-c-common/tags","blobs_url":"https://api.github.com/repos/awslabs/aws-c-common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/awslabs/aws-c-common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/awslabs/aws-c-common/git/refs{/sha}","trees_url":"https://api.github.com/repos/awslabs/aws-c-common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/awslabs/aws-c-common/statuses/{sha}","languages_url":"https://api.github.com/repos/awslabs/aws-c-common/languages","stargazers_url":"https://api.github.com/repos/awslabs/aws-c-common/stargazers","contributors_url":"https://api.github.com/repos/awslabs/aws-c-common/contributors","subscribers_url":"https://api.github.com/repos/awslabs/aws-c-common/subscribers","subscription_url":"https://api.github.com/repos/awslabs/aws-c-common/subscription","commits_url":"https://api.github.com/repos/awslabs/aws-c-common/commits{/sha}","git_commits_url":"https://api.github.com/repos/awslabs/aws-c-common/git/commits{/sha}","comments_url":"https://api.github.com/repos/awslabs/aws-c-common/comments{/number}","issue_comment_url":"https://api.github.com/repos/awslabs/aws-c-common/issues/comments{/number}","contents_url":"https://api.github.com/repos/awslabs/aws-c-common/contents/{+path}","compare_url":"https://api.github.com/repos/awslabs/aws-c-common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/awslabs/aws-c-common/merges","archive_url":"https://api.github.com/repos/awslabs/aws-c-common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/awslabs/aws-c-common/downloads","issues_url":"https://api.github.com/repos/awslabs/aws-c-common/issues{/number}","pulls_url":"https://api.github.com/repos/awslabs/aws-c-common/pulls{/number}","milestones_url":"https://api.github.com/repos/awslabs/aws-c-common/milestones{/number}","notifications_url":"https://api.github.com/repos/awslabs/aws-c-common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/awslabs/aws-c-common/labels{/name}","releases_url":"https://api.github.com/repos/awslabs/aws-c-common/releases{/id}","deployments_url":"https://api.github.com/repos/awslabs/aws-c-common/deployments","created_at":"2018-01-11T19:17:12Z","updated_at":"2018-10-04T00:31:49Z","pushed_at":"2018-10-05T03:18:51Z","git_url":"git://github.com/awslabs/aws-c-common.git","ssh_url":"git@github.com:awslabs/aws-c-common.git","clone_url":"https://github.com/awslabs/aws-c-common.git","svn_url":"https://github.com/awslabs/aws-c-common","homepage":null,"size":780,"stargazers_count":34,"watchers_count":34,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":15,"open_issues":11,"watchers":34,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/awslabs/aws-c-common/pulls/153"},"html":{"href":"https://github.com/awslabs/aws-c-common/pull/153"},"issue":{"href":"https://api.github.com/repos/awslabs/aws-c-common/issues/153"},"comments":{"href":"https://api.github.com/repos/awslabs/aws-c-common/issues/153/comments"},"review_comments":{"href":"https://api.github.com/repos/awslabs/aws-c-common/pulls/153/comments"},"review_comment":{"href":"https://api.github.com/repos/awslabs/aws-c-common/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/awslabs/aws-c-common/pulls/153/commits"},"statuses":{"href":"https://api.github.com/repos/awslabs/aws-c-common/statuses/88742d746d495a7509ca2b5b111d740cc1ff51ed"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"justinboswell"}}