Skip to content

For discussion, possible approach to GafferImage::Warp integer overflow - #7070

Draft
danieldresser-ie wants to merge 1 commit into
GafferHQ:mainfrom
danieldresser-ie:vectorWarpOverflow
Draft

For discussion, possible approach to GafferImage::Warp integer overflow#7070
danieldresser-ie wants to merge 1 commit into
GafferHQ:mainfrom
danieldresser-ie:vectorWarpOverflow

Conversation

@danieldresser-ie

Copy link
Copy Markdown
Contributor

I spent some time today debugging a crash at IE which turned out to be due to invalid inputs to a vector warp.

If the pixel offsets are greater than 2e9, then the size of the input bound needed could wrap around, resulting in trying to do lookups within a zero-sized tile cache.

We should definitely do better than crashing here, but it's probably debateable what the right approach is. Because of how we handle accesses outside the image using the bounding mode, we theoretically could make everything work consistently for floating point values that aren't representable as integers ... but this would result in some fiddly off-by-one issues: we usually store the bound max as the highest index + 1, which if we allow the index to reach MAX_INT, will wrap. So would we need to limit the indices to be no higher than MAX_INT - 1? It's all doable, but a bit fiddly, and we'd want to make sure we don't slow down the common case in order to handle this exceptional case.

For the moment, I've just done the simple thing, of throwing an exception if Warp is run on out-of-bound inputs, to make sure we at least don't crash, and make this much quicker to debug in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant