Tiff seek#873
Conversation
…reusing palettes and image sizes
|
@wiredfool Looks good. Ready for merge? |
|
Actually, It's only passing the test when debugging is on (OMM). There's a really screwy failure where fp.tell is giging a negative number, so that when we seek to it later, it's an error. Reading the opsition before hand seems to be enough that it doesn't fail. I need to take another pass through it to see if there's anything that I'm missing. |
|
Is it returning -1 for error? I think tell() should not give an error unless files were opened with 'r' on windows, which is not the case here. There aren't any 2gig tiff files so the ifdoffset gets turned into a bad signed offset in decode.c, because I didn't know how to pass an unsigned int through PyArg_ParseTuple. There are no such files in the test suite, so that can't be it. In libImaging/TiffDecode.c, filename = "tempfile.tif" is just a descriptive string for a memory buffer, I think, so it is not actually reusing the same physical temp file. None of those seem like a problem. Since it is release only, check to see if the new value, clientstate->ifd is initialized to zero everywhere. Maybe the negative offset you are seeing is not from fp.tell() but is an uninitialized ifdoffset in the TiffDecode.c Maybe old code is calling PyImaging_LibTiffDecoderNew with an args tuple that does not include the ifdoffset. I don't know if that would throw an exception for too few arguments, or if it will give you an undefined value for the last arg. No -- that would fail in debug, too. |
|
It's not -1, it's numbers like -380 or -590. Only on Py3, only when Image.DEBUG is false. It's failing in reading the IFD, called from TiffImagePlugin:_seek. This is in the python only portion of the code, so the libtiff C level changes aren't even part of it. I've pushed the imagesequence test so that it runs both with Image.DEBUG on successfully and fails when it's off. We'll see what travis thinks of it. (though, I'm running on a system that's 99% like travis, so I'm expecting the same thing) |
|
How is it different from the previous code? |
|
When I've gone through it in the debugger, I'm getting the first IFD ok, then the second fails. I think I'll make a minimal test case and go through each commit looking for where it starts to fail that way. |
|
I'm caught up on reproducing this on python3 have fileno, calling fileno version of the decoder. |
|
I made a separate flag now I will try eliminating side effects, or just commenting out debug messages, in case there is some sort of timing issue with python3's io |
|
in TiffImageFile._seek(self, frame) if I just call self.fp.tell() immediately before calling self.fp.seek(self.__next) then everything is magically fixed. |
|
|
Yeah. That's kind of where I ended up. Apparently fp.tell has side effects on py3. I hate spooky side effects. |
|
I'm submitting it as a possible bug to python3, as soon as I get registered. I have a test script that shows the basics of what's happening. I'll link the bug report shortly. Go ahead and get this merged when it passes, and I will start on the tiff tag issues, now that I know how to contribute and test properly. |
|
I couldn't register at python's bug tracker, so It is because of python's buffered io. I'll wait for a better response on SO than "don't use python with established code libraries you moron." I'd really like to know why tell fixes it, but flush does not. |
|
tell is documented as reinitializing py3's buffered io file object |
|
Ah, ok. That does explain it then. That makes me feel a lot better. |
|
See #885 |
This is a cleaned up, single issue version of #865.
It's having some test issues OMM which go away when the tests are run one file at a time in debug mode, so something is likely subtly wrong.
When run as
./test-installed.pyThey don't fail when only running the one test file under debug mode: