Repository navigation
Fill yTileCoords slices tile-relative in InputFile tiled reads - #2879
Dilshad-Tanvi wants to merge 3 commits into
Conversation
InputFile reads scan lines of a tiled part through a one-row tile cache. Channels in the file are copied to yTileCoords slices relative to the first line of the current row of tiles, but fill channels were written relative to the top of the data window, so a frame buffer sized for one row of tiles was written past its end from the second row of tiles on. Pass the tile row's first line to fillBuffer() too. Signed-off-by: Dilshad Tanveer <dilshad@labs.digiscrypt.com>
| } | ||
|
|
||
| for (int y = 0; y < TY; ++y) | ||
| in.readPixels (DY + ty * TY + y); |
There was a problem hiding this comment.
The overall change seems sound to me.
Could you increase test coverage here to try readPixels calls that read a "slice" of more than one scanline at once? The entire read code could iterate multiple times with different size "slices". You could also test reading the file backwards, so the first scanline accessed in a row of tiles isn't the topmost row.
There was a problem hiding this comment.
Makes sense. The test now walks the data window in ranges of 1 to 4 lines (the tile height), forwards and backwards, so the 3-line ranges straddle rows of tiles and going backwards means the first line touched in a row of tiles is its bottom one. It tracks what each row of the one-tile-row buffers should hold and checks all of them after every readPixels call, so untouched rows are confirmed to stay put as well. Still fails under ASan in fillBuffer without the one-line change and passes with it.
Walk the data window in ranges of 1 to TY scan lines, forwards and backwards, instead of one line at a time, so readPixels() ranges straddle rows of tiles and the first line accessed in a row of tiles isn't always its topmost line. Check the whole one-tile-row buffers after every call. Signed-off-by: Dilshad Tanveer <dilshad@labs.digiscrypt.com>
| { | ||
| for (int step = 1; step <= TY; ++step) | ||
| { | ||
| for (int y = 0; y < TY; ++y) |
There was a problem hiding this comment.
it would be more thorough to move the InputFile creation and in.setFrameBuffer call here, so a clean InputFile object is used for each read test
There was a problem hiding this comment.
Good point, the cache state was carrying over between passes. Moved the InputFile and setFrameBuffer in there, so each direction/range-size pass now reads through a fresh object with an empty tile cache. Still clean under ASan with the fix and still an overflow in fillBuffer without it.
Move the InputFile construction and setFrameBuffer() call inside the loop over read directions and range sizes, so every pass starts from an empty tile cache instead of inheriting the previous pass's state. Signed-off-by: Dilshad Tanveer <dilshad@labs.digiscrypt.com>
InputFilereads scan lines of a tiled part through a one-row tile cache inbufferedReadPixels(). Channels that are in the file go throughcopyCachedBuffer()withyStart = tileRange.min.y, so a slice withyTileCoordsset is addressed relative to the first line of the current row of tiles. That is the same conventionTiledInputFileuses, and the whole-imagereadPixels()shortcut inherits it. Channels missing from the file go throughfillBuffer(), which was passeddataWindow.min.yinstead. AyTileCoordsfill slice was therefore addressed from the top of the data window, and a frame buffer sized for one row of tiles is written past its end as soon as a line in the second row of tiles is read. Reading a 16x12 HALF file with 8x4 tiles line by line into 4-rowyTileCoordsslices, with a missingZchannel, gives an ASan heap-buffer-overflow WRITE infillBuffer(ImfInputFile.cpp:721), 0 bytes after the 128-byte fill buffer.Pass
tileRange.min.ytofillBuffer(), matchingcopyCachedBuffer(). Slices withoutyTileCoordsdon't useyStart, so they are unchanged. The newtestTileCoordsFillintestScanLineApi.cppfails without the fix. It is placed away from thetestScanLineApi.cpphunk in #2878, so the two merge cleanly.