New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assert at app exit when opening corrupted image #1817
Comments
I think this was fixed with #1839. Can you confirm? |
It works (1.8.9) |
Just tested it in debug mode and it still shows the assert :( |
J've just tested 1.8.16 and it is still crashing :( As a temporary workaround, I've put "return false" to |
Which assert is it hitting? Is it an OIIO assert? What source file and line does the assert implicate? |
I've debug the issue and it seems that there could be a problem in zlib <-> MSVC.
The _fcloseall func is called automatically when the app exits. This works ok (without an assert):
|
Ah, I see. We are using a different open/close call sequence for open() versus valid_file(). |
We could switch to the other sequence -- fopen(filename), then gzdopen(fileno(f)), for the valid_file (versus doing a direct gzopen(filename). And see if that helps? |
Do you want me to take a stab at a patch to address this? |
I think that closing the file with gzclose should be valid - according to zlib docs, but it is not working in MSVC (?). |
Spurious problems on Windows seem to happen with gzopen(filename) as we used in ZfileInput::valid_file, but not with the gzdopen(fileno(fd)) as we used in ZfileInput::open(). So change valid_file to the method that seems to work. This has been linked to crashes during app shutdown on Windows (even when no zfiles are encountered, since it can happen with invalid files when all input readers are tried). Also add a zfile testsuite entry. Fixes AcademySoftwareFoundation#1817
Proposed fix in #2070. @riviera-kid, I've never seen the crash, so I'm going to need to rely on you to try it out on your end with the debug build and see if it appears to clear up the problem. |
Spurious problems on Windows seem to happen with gzopen(filename) as we used in ZfileInput::valid_file, but not with the gzdopen(fileno(fd)) as we used in ZfileInput::open(). So change valid_file to the method that seems to work. This has been linked to crashes during app shutdown on Windows (even when no zfiles are encountered, since it can happen with invalid files when all input readers are tried). Also add a zfile testsuite entry. Fixes AcademySoftwareFoundation#1817
Spurious problems on Windows seem to happen with gzopen(filename) as we used in ZfileInput::valid_file, but not with the gzdopen(fileno(fd)) as we used in ZfileInput::open(). So change valid_file to the method that seems to work. This has been linked to crashes during app shutdown on Windows (even when no zfiles are encountered, since it can happen with invalid files when all input readers are tried). Also add a zfile testsuite entry. Fixes AcademySoftwareFoundation#1817
Spurious problems on Windows seem to happen with improperly closed or leaking file handles. Solved by using gzopen_w on Windows to handle UTF-8 filenames allows us to remove the odd idiom of opening with fopen() then passing fileno to gzdopen (we were botching exactly who was responsible for duplicating or closing those handles). Also add a zfile testsuite entry. Fixes #1817
Spurious problems on Windows seem to happen with improperly closed or leaking file handles. Solved by using gzopen_w on Windows to handle UTF-8 filenames allows us to remove the odd idiom of opening with fopen() then passing fileno to gzdopen (we were botching exactly who was responsible for duplicating or closing those handles). Also add a zfile testsuite entry. Fixes AcademySoftwareFoundation#1817
Spurious problems on Windows seem to happen with improperly closed or leaking file handles. Solved by using gzopen_w on Windows to handle UTF-8 filenames allows us to remove the odd idiom of opening with fopen() then passing fileno to gzdopen (we were botching exactly who was responsible for duplicating or closing those handles). Also add a zfile testsuite entry. Fixes AcademySoftwareFoundation#1817
Spurious problems on Windows seem to happen with improperly closed or leaking file handles. Solved by using gzopen_w on Windows to handle UTF-8 filenames allows us to remove the odd idiom of opening with fopen() then passing fileno to gzdopen (we were botching exactly who was responsible for duplicating or closing those handles). Also add a zfile testsuite entry. Fixes AcademySoftwareFoundation#1817
Problem
This simple program shows assert at exit:
#include <OpenImageIO/imageio.h>
int main()
{
OIIO::ImageInput *in = OIIO::ImageInput::open("obrtest.png");
//_fcloseall();
return 0;
}
obrtest.png:
The problem is probably related to Windows - Visual Studio - zlib.
If the file is invalid, then all plugins are tried (including zfile plugin).
It seems that there can be a problem in zfile.cpp with closing file handles in zlib and msvc.
The included program shows me in debug mode an assert at app exit (or calling _fcloseall manually):
Expression: (_osfile(fh) & FOPEN)
And it also crashes in release mode on some machines.
When I exclude the zfile plugin from the OIIO lib, it works - but there could be a better solution...
Versions
The text was updated successfully, but these errors were encountered: