{"action":"closed","number":283,"pull_request":{"url":"https://api.github.com/repos/ocaml/ocaml/pulls/283","id":49974441,"html_url":"https://github.com/ocaml/ocaml/pull/283","diff_url":"https://github.com/ocaml/ocaml/pull/283.diff","patch_url":"https://github.com/ocaml/ocaml/pull/283.patch","issue_url":"https://api.github.com/repos/ocaml/ocaml/issues/283","number":283,"state":"closed","locked":false,"title":"Fix memory leaks in intern.c when OOM is raised","user":{"login":"mlasson","id":5814258,"avatar_url":"https://avatars.githubusercontent.com/u/5814258?v=3","gravatar_id":"","url":"https://api.github.com/users/mlasson","html_url":"https://github.com/mlasson","followers_url":"https://api.github.com/users/mlasson/followers","following_url":"https://api.github.com/users/mlasson/following{/other_user}","gists_url":"https://api.github.com/users/mlasson/gists{/gist_id}","starred_url":"https://api.github.com/users/mlasson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlasson/subscriptions","organizations_url":"https://api.github.com/users/mlasson/orgs","repos_url":"https://api.github.com/users/mlasson/repos","events_url":"https://api.github.com/users/mlasson/events{/privacy}","received_events_url":"https://api.github.com/users/mlasson/received_events","type":"User","site_admin":false},"body":"In the function, `intern_alloc` a call to caml_alloc_for_heap is very likely to\r\nreturn NULL when reading a big marshaled value. If that happens, before raising\r\nout_of_memory, it should call the `intern_cleanup` function to free the stack\r\nas well as `intern_input` that may have been malloced by `caml_input_val`.\r\nSimilarly, `intern_cleanup` should also be called when we are not able to\r\nallocate `intern_obj_table`. To do that, I added a function\r\n`caml_stat_alloc_no_raise` which, like its brother, `caml_stat_alloc` wraps\r\nsome debugging information around a call to malloc. I could have used directly\r\nmalloc instead of adding a new function to memory.c, as it is done in other\r\nplaces of the code (it has the drawback of not adding the debug tag).\r\n\r\nNote that this fix is not perfect. The function `intern_alloc` could also raise\r\nout_of_memory through its call to `caml_alloc_shr`. It is less likely to happen\r\nsince caml_alloc_shr is only called when the input is smaller than Max_wosize\r\nbut it could happen. In that case, there will be leak (but a smaller one).","created_at":"2015-11-06T16:30:59Z","updated_at":"2015-11-23T12:25:34Z","closed_at":"2015-11-23T12:25:34Z","merged_at":"2015-11-23T12:25:34Z","merge_commit_sha":"eeaab4d168637b220dab2d5d5ca0842a9df9d813","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ocaml/ocaml/pulls/283/commits","review_comments_url":"https://api.github.com/repos/ocaml/ocaml/pulls/283/comments","review_comment_url":"https://api.github.com/repos/ocaml/ocaml/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ocaml/ocaml/issues/283/comments","statuses_url":"https://api.github.com/repos/ocaml/ocaml/statuses/bf0fc9fc9c8166053eb53bc869059ffb028b74d1","head":{"label":"mlasson:trunk","ref":"trunk","sha":"bf0fc9fc9c8166053eb53bc869059ffb028b74d1","user":{"login":"mlasson","id":5814258,"avatar_url":"https://avatars.githubusercontent.com/u/5814258?v=3","gravatar_id":"","url":"https://api.github.com/users/mlasson","html_url":"https://github.com/mlasson","followers_url":"https://api.github.com/users/mlasson/followers","following_url":"https://api.github.com/users/mlasson/following{/other_user}","gists_url":"https://api.github.com/users/mlasson/gists{/gist_id}","starred_url":"https://api.github.com/users/mlasson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlasson/subscriptions","organizations_url":"https://api.github.com/users/mlasson/orgs","repos_url":"https://api.github.com/users/mlasson/repos","events_url":"https://api.github.com/users/mlasson/events{/privacy}","received_events_url":"https://api.github.com/users/mlasson/received_events","type":"User","site_admin":false},"repo":{"id":45684315,"name":"ocaml","full_name":"mlasson/ocaml","owner":{"login":"mlasson","id":5814258,"avatar_url":"https://avatars.githubusercontent.com/u/5814258?v=3","gravatar_id":"","url":"https://api.github.com/users/mlasson","html_url":"https://github.com/mlasson","followers_url":"https://api.github.com/users/mlasson/followers","following_url":"https://api.github.com/users/mlasson/following{/other_user}","gists_url":"https://api.github.com/users/mlasson/gists{/gist_id}","starred_url":"https://api.github.com/users/mlasson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlasson/subscriptions","organizations_url":"https://api.github.com/users/mlasson/orgs","repos_url":"https://api.github.com/users/mlasson/repos","events_url":"https://api.github.com/users/mlasson/events{/privacy}","received_events_url":"https://api.github.com/users/mlasson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mlasson/ocaml","description":"The core OCaml system: compilers, runtime system, base libraries","fork":true,"url":"https://api.github.com/repos/mlasson/ocaml","forks_url":"https://api.github.com/repos/mlasson/ocaml/forks","keys_url":"https://api.github.com/repos/mlasson/ocaml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mlasson/ocaml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mlasson/ocaml/teams","hooks_url":"https://api.github.com/repos/mlasson/ocaml/hooks","issue_events_url":"https://api.github.com/repos/mlasson/ocaml/issues/events{/number}","events_url":"https://api.github.com/repos/mlasson/ocaml/events","assignees_url":"https://api.github.com/repos/mlasson/ocaml/assignees{/user}","branches_url":"https://api.github.com/repos/mlasson/ocaml/branches{/branch}","tags_url":"https://api.github.com/repos/mlasson/ocaml/tags","blobs_url":"https://api.github.com/repos/mlasson/ocaml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mlasson/ocaml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mlasson/ocaml/git/refs{/sha}","trees_url":"https://api.github.com/repos/mlasson/ocaml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mlasson/ocaml/statuses/{sha}","languages_url":"https://api.github.com/repos/mlasson/ocaml/languages","stargazers_url":"https://api.github.com/repos/mlasson/ocaml/stargazers","contributors_url":"https://api.github.com/repos/mlasson/ocaml/contributors","subscribers_url":"https://api.github.com/repos/mlasson/ocaml/subscribers","subscription_url":"https://api.github.com/repos/mlasson/ocaml/subscription","commits_url":"https://api.github.com/repos/mlasson/ocaml/commits{/sha}","git_commits_url":"https://api.github.com/repos/mlasson/ocaml/git/commits{/sha}","comments_url":"https://api.github.com/repos/mlasson/ocaml/comments{/number}","issue_comment_url":"https://api.github.com/repos/mlasson/ocaml/issues/comments{/number}","contents_url":"https://api.github.com/repos/mlasson/ocaml/contents/{+path}","compare_url":"https://api.github.com/repos/mlasson/ocaml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mlasson/ocaml/merges","archive_url":"https://api.github.com/repos/mlasson/ocaml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mlasson/ocaml/downloads","issues_url":"https://api.github.com/repos/mlasson/ocaml/issues{/number}","pulls_url":"https://api.github.com/repos/mlasson/ocaml/pulls{/number}","milestones_url":"https://api.github.com/repos/mlasson/ocaml/milestones{/number}","notifications_url":"https://api.github.com/repos/mlasson/ocaml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mlasson/ocaml/labels{/name}","releases_url":"https://api.github.com/repos/mlasson/ocaml/releases{/id}","created_at":"2015-11-06T13:42:54Z","updated_at":"2015-11-06T13:43:12Z","pushed_at":"2015-11-23T11:10:16Z","git_url":"git://github.com/mlasson/ocaml.git","ssh_url":"git@github.com:mlasson/ocaml.git","clone_url":"https://github.com/mlasson/ocaml.git","svn_url":"https://github.com/mlasson/ocaml","homepage":"","size":103294,"stargazers_count":0,"watchers_count":0,"language":"OCaml","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"ocaml:trunk","ref":"trunk","sha":"60e7055d9f0393ceb09c0b7336ca75779a4bed21","user":{"login":"ocaml","id":1841483,"avatar_url":"https://avatars.githubusercontent.com/u/1841483?v=3","gravatar_id":"","url":"https://api.github.com/users/ocaml","html_url":"https://github.com/ocaml","followers_url":"https://api.github.com/users/ocaml/followers","following_url":"https://api.github.com/users/ocaml/following{/other_user}","gists_url":"https://api.github.com/users/ocaml/gists{/gist_id}","starred_url":"https://api.github.com/users/ocaml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocaml/subscriptions","organizations_url":"https://api.github.com/users/ocaml/orgs","repos_url":"https://api.github.com/users/ocaml/repos","events_url":"https://api.github.com/users/ocaml/events{/privacy}","received_events_url":"https://api.github.com/users/ocaml/received_events","type":"Organization","site_admin":false},"repo":{"id":6786166,"name":"ocaml","full_name":"ocaml/ocaml","owner":{"login":"ocaml","id":1841483,"avatar_url":"https://avatars.githubusercontent.com/u/1841483?v=3","gravatar_id":"","url":"https://api.github.com/users/ocaml","html_url":"https://github.com/ocaml","followers_url":"https://api.github.com/users/ocaml/followers","following_url":"https://api.github.com/users/ocaml/following{/other_user}","gists_url":"https://api.github.com/users/ocaml/gists{/gist_id}","starred_url":"https://api.github.com/users/ocaml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocaml/subscriptions","organizations_url":"https://api.github.com/users/ocaml/orgs","repos_url":"https://api.github.com/users/ocaml/repos","events_url":"https://api.github.com/users/ocaml/events{/privacy}","received_events_url":"https://api.github.com/users/ocaml/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ocaml/ocaml","description":"The core OCaml system: compilers, runtime system, base libraries","fork":false,"url":"https://api.github.com/repos/ocaml/ocaml","forks_url":"https://api.github.com/repos/ocaml/ocaml/forks","keys_url":"https://api.github.com/repos/ocaml/ocaml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ocaml/ocaml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ocaml/ocaml/teams","hooks_url":"https://api.github.com/repos/ocaml/ocaml/hooks","issue_events_url":"https://api.github.com/repos/ocaml/ocaml/issues/events{/number}","events_url":"https://api.github.com/repos/ocaml/ocaml/events","assignees_url":"https://api.github.com/repos/ocaml/ocaml/assignees{/user}","branches_url":"https://api.github.com/repos/ocaml/ocaml/branches{/branch}","tags_url":"https://api.github.com/repos/ocaml/ocaml/tags","blobs_url":"https://api.github.com/repos/ocaml/ocaml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ocaml/ocaml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ocaml/ocaml/git/refs{/sha}","trees_url":"https://api.github.com/repos/ocaml/ocaml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ocaml/ocaml/statuses/{sha}","languages_url":"https://api.github.com/repos/ocaml/ocaml/languages","stargazers_url":"https://api.github.com/repos/ocaml/ocaml/stargazers","contributors_url":"https://api.github.com/repos/ocaml/ocaml/contributors","subscribers_url":"https://api.github.com/repos/ocaml/ocaml/subscribers","subscription_url":"https://api.github.com/repos/ocaml/ocaml/subscription","commits_url":"https://api.github.com/repos/ocaml/ocaml/commits{/sha}","git_commits_url":"https://api.github.com/repos/ocaml/ocaml/git/commits{/sha}","comments_url":"https://api.github.com/repos/ocaml/ocaml/comments{/number}","issue_comment_url":"https://api.github.com/repos/ocaml/ocaml/issues/comments{/number}","contents_url":"https://api.github.com/repos/ocaml/ocaml/contents/{+path}","compare_url":"https://api.github.com/repos/ocaml/ocaml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ocaml/ocaml/merges","archive_url":"https://api.github.com/repos/ocaml/ocaml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ocaml/ocaml/downloads","issues_url":"https://api.github.com/repos/ocaml/ocaml/issues{/number}","pulls_url":"https://api.github.com/repos/ocaml/ocaml/pulls{/number}","milestones_url":"https://api.github.com/repos/ocaml/ocaml/milestones{/number}","notifications_url":"https://api.github.com/repos/ocaml/ocaml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ocaml/ocaml/labels{/name}","releases_url":"https://api.github.com/repos/ocaml/ocaml/releases{/id}","created_at":"2012-11-20T22:18:22Z","updated_at":"2015-11-23T08:14:47Z","pushed_at":"2015-11-23T12:25:34Z","git_url":"git://github.com/ocaml/ocaml.git","ssh_url":"git@github.com:ocaml/ocaml.git","clone_url":"https://github.com/ocaml/ocaml.git","svn_url":"https://github.com/ocaml/ocaml","homepage":"","size":147346,"stargazers_count":548,"watchers_count":548,"language":"OCaml","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":190,"mirror_url":null,"open_issues_count":68,"forks":190,"open_issues":68,"watchers":548,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/283"},"html":{"href":"https://github.com/ocaml/ocaml/pull/283"},"issue":{"href":"https://api.github.com/repos/ocaml/ocaml/issues/283"},"comments":{"href":"https://api.github.com/repos/ocaml/ocaml/issues/283/comments"},"review_comments":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/283/comments"},"review_comment":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/283/commits"},"statuses":{"href":"https://api.github.com/repos/ocaml/ocaml/statuses/bf0fc9fc9c8166053eb53bc869059ffb028b74d1"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"alainfrisch","id":3305274,"avatar_url":"https://avatars.githubusercontent.com/u/3305274?v=3","gravatar_id":"","url":"https://api.github.com/users/alainfrisch","html_url":"https://github.com/alainfrisch","followers_url":"https://api.github.com/users/alainfrisch/followers","following_url":"https://api.github.com/users/alainfrisch/following{/other_user}","gists_url":"https://api.github.com/users/alainfrisch/gists{/gist_id}","starred_url":"https://api.github.com/users/alainfrisch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alainfrisch/subscriptions","organizations_url":"https://api.github.com/users/alainfrisch/orgs","repos_url":"https://api.github.com/users/alainfrisch/repos","events_url":"https://api.github.com/users/alainfrisch/events{/privacy}","received_events_url":"https://api.github.com/users/alainfrisch/received_events","type":"User","site_admin":false},"comments":30,"review_comments":3,"commits":16,"additions":100,"deletions":54,"changed_files":5}}