{"action":"created","comment":{"url":"https://api.github.com/repos/halide/Halide/pulls/comments/62748472","id":62748472,"diff_hunk":"@@ -3,16 +3,32 @@\n #include \"Error.h\"\n #include \"JITModule.h\"\n #include \"runtime/HalideRuntime.h\"\n+#include \"Target.h\"\n \n namespace Halide {\n namespace Internal {\n \n namespace {\n-void check_buffer_size(uint64_t bytes, const std::string &name) {\n-    user_assert(bytes < (1UL << 31)) << \"Total size of buffer \" << name << \" exceeds 2^31 - 1\\n\";\n-}\n+\n+uint64_t multiply_buffer_size_check_overflow(uint64_t size, uint64_t factor, const std::string &name) {\n+    // Ignore the dimensions for which the extent is zero.\n+    if (!factor) return size;\n+\n+    // Multiply and check for 64-bit overflow\n+    uint64_t result = size * factor;\n+    bool overflow = (result / factor) != size;\n+\n+    // Check against the limits Halide internally assumes in its compiled code.\n+    overflow |= (sizeof(void *) == 4) && (result >= (1UL << 31));","path":"src/Buffer.cpp","position":23,"original_position":23,"commit_id":"259606af8860d62bc56329b7376f17f1f608700e","original_commit_id":"e8610f3edce8d2d033e6b1d4f3b5959fafcfd8fe","user":{"login":"zvookin","id":1501716,"avatar_url":"https://avatars.githubusercontent.com/u/1501716?v=3","gravatar_id":"","url":"https://api.github.com/users/zvookin","html_url":"https://github.com/zvookin","followers_url":"https://api.github.com/users/zvookin/followers","following_url":"https://api.github.com/users/zvookin/following{/other_user}","gists_url":"https://api.github.com/users/zvookin/gists{/gist_id}","starred_url":"https://api.github.com/users/zvookin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zvookin/subscriptions","organizations_url":"https://api.github.com/users/zvookin/orgs","repos_url":"https://api.github.com/users/zvookin/repos","events_url":"https://api.github.com/users/zvookin/events{/privacy}","received_events_url":"https://api.github.com/users/zvookin/received_events","type":"User","site_admin":false},"body":"This seems to be automatically choosing large buffers if compiled in 64-bit mode. Is this always true? I would expect in the default case for both 32-bit and 64-bit processes that LargeBuffers is not set. Two possible solutions are to get the JIT target to decide which check to use, or to change the comment to say this is a conservative check and that in a 64-bit process a filter is not using the LargeBuffer feature may still signal a buffer too large error at call time.\r\n\r\nAlso I might use sizeof(size_t) rather than sizeof(void *). Not 100% sure, but in theory 64-bit pointer with 32-bit max allocation is a possible thing.\r\n","created_at":"2016-05-10T20:43:56Z","updated_at":"2016-05-10T20:43:56Z","html_url":"https://github.com/halide/Halide/pull/1199#discussion_r62748472","pull_request_url":"https://api.github.com/repos/halide/Halide/pulls/1199","_links":{"self":{"href":"https://api.github.com/repos/halide/Halide/pulls/comments/62748472"},"html":{"href":"https://github.com/halide/Halide/pull/1199#discussion_r62748472"},"pull_request":{"href":"https://api.github.com/repos/halide/Halide/pulls/1199"}}},"pull_request":{"url":"https://api.github.com/repos/halide/Halide/pulls/1199","id":69570236,"html_url":"https://github.com/halide/Halide/pull/1199","diff_url":"https://github.com/halide/Halide/pull/1199.diff","patch_url":"https://github.com/halide/Halide/pull/1199.patch","issue_url":"https://api.github.com/repos/halide/Halide/issues/1199","number":1199,"state":"open","locked":false,"title":"large buffers","user":{"login":"abadams","id":515398,"avatar_url":"https://avatars.githubusercontent.com/u/515398?v=3","gravatar_id":"","url":"https://api.github.com/users/abadams","html_url":"https://github.com/abadams","followers_url":"https://api.github.com/users/abadams/followers","following_url":"https://api.github.com/users/abadams/following{/other_user}","gists_url":"https://api.github.com/users/abadams/gists{/gist_id}","starred_url":"https://api.github.com/users/abadams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abadams/subscriptions","organizations_url":"https://api.github.com/users/abadams/orgs","repos_url":"https://api.github.com/users/abadams/repos","events_url":"https://api.github.com/users/abadams/events{/privacy}","received_events_url":"https://api.github.com/users/abadams/received_events","type":"User","site_admin":false},"body":"This is a modification and simplification of #952 . It uses a more conservative simplifier rule, and fixes some test breakages.","created_at":"2016-05-10T20:15:09Z","updated_at":"2016-05-10T20:43:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2b36fc65ff38b386cf36150f604827dbc207f25a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/halide/Halide/pulls/1199/commits","review_comments_url":"https://api.github.com/repos/halide/Halide/pulls/1199/comments","review_comment_url":"https://api.github.com/repos/halide/Halide/pulls/comments{/number}","comments_url":"https://api.github.com/repos/halide/Halide/issues/1199/comments","statuses_url":"https://api.github.com/repos/halide/Halide/statuses/259606af8860d62bc56329b7376f17f1f608700e","head":{"label":"halide:tdenniston-large-buffers","ref":"tdenniston-large-buffers","sha":"259606af8860d62bc56329b7376f17f1f608700e","user":{"login":"halide","id":1548551,"avatar_url":"https://avatars.githubusercontent.com/u/1548551?v=3","gravatar_id":"","url":"https://api.github.com/users/halide","html_url":"https://github.com/halide","followers_url":"https://api.github.com/users/halide/followers","following_url":"https://api.github.com/users/halide/following{/other_user}","gists_url":"https://api.github.com/users/halide/gists{/gist_id}","starred_url":"https://api.github.com/users/halide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halide/subscriptions","organizations_url":"https://api.github.com/users/halide/orgs","repos_url":"https://api.github.com/users/halide/repos","events_url":"https://api.github.com/users/halide/events{/privacy}","received_events_url":"https://api.github.com/users/halide/received_events","type":"Organization","site_admin":false},"repo":{"id":5241312,"name":"Halide","full_name":"halide/Halide","owner":{"login":"halide","id":1548551,"avatar_url":"https://avatars.githubusercontent.com/u/1548551?v=3","gravatar_id":"","url":"https://api.github.com/users/halide","html_url":"https://github.com/halide","followers_url":"https://api.github.com/users/halide/followers","following_url":"https://api.github.com/users/halide/following{/other_user}","gists_url":"https://api.github.com/users/halide/gists{/gist_id}","starred_url":"https://api.github.com/users/halide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halide/subscriptions","organizations_url":"https://api.github.com/users/halide/orgs","repos_url":"https://api.github.com/users/halide/repos","events_url":"https://api.github.com/users/halide/events{/privacy}","received_events_url":"https://api.github.com/users/halide/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/halide/Halide","description":"a language for image processing and computational photography","fork":false,"url":"https://api.github.com/repos/halide/Halide","forks_url":"https://api.github.com/repos/halide/Halide/forks","keys_url":"https://api.github.com/repos/halide/Halide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/halide/Halide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/halide/Halide/teams","hooks_url":"https://api.github.com/repos/halide/Halide/hooks","issue_events_url":"https://api.github.com/repos/halide/Halide/issues/events{/number}","events_url":"https://api.github.com/repos/halide/Halide/events","assignees_url":"https://api.github.com/repos/halide/Halide/assignees{/user}","branches_url":"https://api.github.com/repos/halide/Halide/branches{/branch}","tags_url":"https://api.github.com/repos/halide/Halide/tags","blobs_url":"https://api.github.com/repos/halide/Halide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/halide/Halide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/halide/Halide/git/refs{/sha}","trees_url":"https://api.github.com/repos/halide/Halide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/halide/Halide/statuses/{sha}","languages_url":"https://api.github.com/repos/halide/Halide/languages","stargazers_url":"https://api.github.com/repos/halide/Halide/stargazers","contributors_url":"https://api.github.com/repos/halide/Halide/contributors","subscribers_url":"https://api.github.com/repos/halide/Halide/subscribers","subscription_url":"https://api.github.com/repos/halide/Halide/subscription","commits_url":"https://api.github.com/repos/halide/Halide/commits{/sha}","git_commits_url":"https://api.github.com/repos/halide/Halide/git/commits{/sha}","comments_url":"https://api.github.com/repos/halide/Halide/comments{/number}","issue_comment_url":"https://api.github.com/repos/halide/Halide/issues/comments{/number}","contents_url":"https://api.github.com/repos/halide/Halide/contents/{+path}","compare_url":"https://api.github.com/repos/halide/Halide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/halide/Halide/merges","archive_url":"https://api.github.com/repos/halide/Halide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/halide/Halide/downloads","issues_url":"https://api.github.com/repos/halide/Halide/issues{/number}","pulls_url":"https://api.github.com/repos/halide/Halide/pulls{/number}","milestones_url":"https://api.github.com/repos/halide/Halide/milestones{/number}","notifications_url":"https://api.github.com/repos/halide/Halide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/halide/Halide/labels{/name}","releases_url":"https://api.github.com/repos/halide/Halide/releases{/id}","deployments_url":"https://api.github.com/repos/halide/Halide/deployments","created_at":"2012-07-31T04:05:25Z","updated_at":"2016-05-10T08:14:52Z","pushed_at":"2016-05-10T20:32:12Z","git_url":"git://github.com/halide/Halide.git","ssh_url":"git@github.com:halide/Halide.git","clone_url":"https://github.com/halide/Halide.git","svn_url":"https://github.com/halide/Halide","homepage":"http://halide-lang.org","size":263659,"stargazers_count":1283,"watchers_count":1283,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":254,"mirror_url":null,"open_issues_count":179,"forks":254,"open_issues":179,"watchers":1283,"default_branch":"master"}},"base":{"label":"halide:master","ref":"master","sha":"62df252d50aaed10b4153c8884f6462dd9143e15","user":{"login":"halide","id":1548551,"avatar_url":"https://avatars.githubusercontent.com/u/1548551?v=3","gravatar_id":"","url":"https://api.github.com/users/halide","html_url":"https://github.com/halide","followers_url":"https://api.github.com/users/halide/followers","following_url":"https://api.github.com/users/halide/following{/other_user}","gists_url":"https://api.github.com/users/halide/gists{/gist_id}","starred_url":"https://api.github.com/users/halide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halide/subscriptions","organizations_url":"https://api.github.com/users/halide/orgs","repos_url":"https://api.github.com/users/halide/repos","events_url":"https://api.github.com/users/halide/events{/privacy}","received_events_url":"https://api.github.com/users/halide/received_events","type":"Organization","site_admin":false},"repo":{"id":5241312,"name":"Halide","full_name":"halide/Halide","owner":{"login":"halide","id":1548551,"avatar_url":"https://avatars.githubusercontent.com/u/1548551?v=3","gravatar_id":"","url":"https://api.github.com/users/halide","html_url":"https://github.com/halide","followers_url":"https://api.github.com/users/halide/followers","following_url":"https://api.github.com/users/halide/following{/other_user}","gists_url":"https://api.github.com/users/halide/gists{/gist_id}","starred_url":"https://api.github.com/users/halide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halide/subscriptions","organizations_url":"https://api.github.com/users/halide/orgs","repos_url":"https://api.github.com/users/halide/repos","events_url":"https://api.github.com/users/halide/events{/privacy}","received_events_url":"https://api.github.com/users/halide/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/halide/Halide","description":"a language for image processing and computational photography","fork":false,"url":"https://api.github.com/repos/halide/Halide","forks_url":"https://api.github.com/repos/halide/Halide/forks","keys_url":"https://api.github.com/repos/halide/Halide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/halide/Halide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/halide/Halide/teams","hooks_url":"https://api.github.com/repos/halide/Halide/hooks","issue_events_url":"https://api.github.com/repos/halide/Halide/issues/events{/number}","events_url":"https://api.github.com/repos/halide/Halide/events","assignees_url":"https://api.github.com/repos/halide/Halide/assignees{/user}","branches_url":"https://api.github.com/repos/halide/Halide/branches{/branch}","tags_url":"https://api.github.com/repos/halide/Halide/tags","blobs_url":"https://api.github.com/repos/halide/Halide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/halide/Halide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/halide/Halide/git/refs{/sha}","trees_url":"https://api.github.com/repos/halide/Halide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/halide/Halide/statuses/{sha}","languages_url":"https://api.github.com/repos/halide/Halide/languages","stargazers_url":"https://api.github.com/repos/halide/Halide/stargazers","contributors_url":"https://api.github.com/repos/halide/Halide/contributors","subscribers_url":"https://api.github.com/repos/halide/Halide/subscribers","subscription_url":"https://api.github.com/repos/halide/Halide/subscription","commits_url":"https://api.github.com/repos/halide/Halide/commits{/sha}","git_commits_url":"https://api.github.com/repos/halide/Halide/git/commits{/sha}","comments_url":"https://api.github.com/repos/halide/Halide/comments{/number}","issue_comment_url":"https://api.github.com/repos/halide/Halide/issues/comments{/number}","contents_url":"https://api.github.com/repos/halide/Halide/contents/{+path}","compare_url":"https://api.github.com/repos/halide/Halide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/halide/Halide/merges","archive_url":"https://api.github.com/repos/halide/Halide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/halide/Halide/downloads","issues_url":"https://api.github.com/repos/halide/Halide/issues{/number}","pulls_url":"https://api.github.com/repos/halide/Halide/pulls{/number}","milestones_url":"https://api.github.com/repos/halide/Halide/milestones{/number}","notifications_url":"https://api.github.com/repos/halide/Halide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/halide/Halide/labels{/name}","releases_url":"https://api.github.com/repos/halide/Halide/releases{/id}","deployments_url":"https://api.github.com/repos/halide/Halide/deployments","created_at":"2012-07-31T04:05:25Z","updated_at":"2016-05-10T08:14:52Z","pushed_at":"2016-05-10T20:32:12Z","git_url":"git://github.com/halide/Halide.git","ssh_url":"git@github.com:halide/Halide.git","clone_url":"https://github.com/halide/Halide.git","svn_url":"https://github.com/halide/Halide","homepage":"http://halide-lang.org","size":263659,"stargazers_count":1283,"watchers_count":1283,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":254,"mirror_url":null,"open_issues_count":179,"forks":254,"open_issues":179,"watchers":1283,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/halide/Halide/pulls/1199"},"html":{"href":"https://github.com/halide/Halide/pull/1199"},"issue":{"href":"https://api.github.com/repos/halide/Halide/issues/1199"},"comments":{"href":"https://api.github.com/repos/halide/Halide/issues/1199/comments"},"review_comments":{"href":"https://api.github.com/repos/halide/Halide/pulls/1199/comments"},"review_comment":{"href":"https://api.github.com/repos/halide/Halide/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/halide/Halide/pulls/1199/commits"},"statuses":{"href":"https://api.github.com/repos/halide/Halide/statuses/259606af8860d62bc56329b7376f17f1f608700e"}}}}