{"action":"created","issue":{"url":"https://api.github.com/repos/cinder/Cinder/issues/1410","repository_url":"https://api.github.com/repos/cinder/Cinder","labels_url":"https://api.github.com/repos/cinder/Cinder/issues/1410/labels{/name}","comments_url":"https://api.github.com/repos/cinder/Cinder/issues/1410/comments","events_url":"https://api.github.com/repos/cinder/Cinder/issues/1410/events","html_url":"https://github.com/cinder/Cinder/pull/1410","id":145329024,"number":1410,"title":"Allow Surfaces larger than 2GiB","user":{"login":"notlion","id":27721,"avatar_url":"https://avatars.githubusercontent.com/u/27721?v=3","gravatar_id":"","url":"https://api.github.com/users/notlion","html_url":"https://github.com/notlion","followers_url":"https://api.github.com/users/notlion/followers","following_url":"https://api.github.com/users/notlion/following{/other_user}","gists_url":"https://api.github.com/users/notlion/gists{/gist_id}","starred_url":"https://api.github.com/users/notlion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/notlion/subscriptions","organizations_url":"https://api.github.com/users/notlion/orgs","repos_url":"https://api.github.com/users/notlion/repos","events_url":"https://api.github.com/users/notlion/events{/privacy}","received_events_url":"https://api.github.com/users/notlion/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-02T02:59:07Z","updated_at":"2016-04-03T02:52:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cinder/Cinder/pulls/1410","html_url":"https://github.com/cinder/Cinder/pull/1410","diff_url":"https://github.com/cinder/Cinder/pull/1410.diff","patch_url":"https://github.com/cinder/Cinder/pull/1410.patch"},"body":"Allow Surfaces larger than 2GiB\r\n\r\nPreviously creating surfaces larger than 2^31 bytes would cause an int32_t overflow on data size calculation, throwing a bad_alloc exception.\r\n\r\nThis commit converts mRowBytes, mInc and mRowInc to size_t, which causes size calculations to be performed in size_t before the result is used for array allocation and pointer arithmetic. Also, sites where these variables are used have been converted to avoid loss of precision."},"comment":{"url":"https://api.github.com/repos/cinder/Cinder/issues/comments/204858625","html_url":"https://github.com/cinder/Cinder/pull/1410#issuecomment-204858625","issue_url":"https://api.github.com/repos/cinder/Cinder/issues/1410","id":204858625,"user":{"login":"andrewfb","id":227107,"avatar_url":"https://avatars.githubusercontent.com/u/227107?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewfb","html_url":"https://github.com/andrewfb","followers_url":"https://api.github.com/users/andrewfb/followers","following_url":"https://api.github.com/users/andrewfb/following{/other_user}","gists_url":"https://api.github.com/users/andrewfb/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewfb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewfb/subscriptions","organizations_url":"https://api.github.com/users/andrewfb/orgs","repos_url":"https://api.github.com/users/andrewfb/repos","events_url":"https://api.github.com/users/andrewfb/events{/privacy}","received_events_url":"https://api.github.com/users/andrewfb/received_events","type":"User","site_admin":false},"created_at":"2016-04-03T02:52:05Z","updated_at":"2016-04-03T02:52:05Z","body":"Thanks for taking a look at this - definitely interested to improve Cinder's large image support.\r\n\r\nThis change brings up a few subtle issues I think. One you mentioned Ryan is that the reason this change works is that it promotes rowbytes-dependent math to 64-bit; the value itself does not need to be 64-bit however, unless your image is wider than 2^29. `mPixelInc` should remain 8-bit as it basically correlates to the number of channels in the image. Also in some platforms, rowbytes can be negative (MSW images from GDI, for example), so a wholesale change to `size_t` is probably not ideal.\r\n\r\nAnother option might be to switch to `int64_t`. However I'm not confident that doesn't have performance implications on ARM in particular, and this is a case where that perf difference might be significant.\r\n\r\nMy first thought would be that we would prefer large image support on 64-bit machines, and to keep things essentially as they are on 32-bit machines. To that end, I'm curious if simply changing `mRowBytes` (and of course `getRowByes()`) to `ptrdiff_t` solves the use case you're seeing?\r\n"}}