-
Notifications
You must be signed in to change notification settings - Fork 603
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
[BUG] assert_fail is called #4388
Comments
My guess is that somewhere there is an error message or some other formatting that isn't needed very commonly and isn't encountered in the testsuite, in which the arguments don't match the format string. You seem to be in a debugger, can you go up the stack frame and fine the format/print statement in OIIO that triggers the assert? Also, in our fmt.h, there's a line that says |
It’s a release mode build with symbols in the debugger. The stack that is displayed in the image is all I have. I am trying to repro in debug mode, but I have not been able to so far. I use vcpkg, I will see if there is a simple way to set that define. |
Is this behavior something that could be moved to runtime vs. compile time? |
I think that in sufficiently advanced C++ standard, a bunch of it may become constexpr and thus compile-time checkable. Short of that, I think it is possible to fix this to be compile checkable, if we can find the place where it happens (or the much larger job of fixing EVERY place where strings are formatted). I think it would be fine to stop suppressing the fmt exceptions. I guess it would be problematic if we called it and it threw from within some API call we currently declare as |
More info. buffer contents in vprint_buffered "OpenImageIO exited with a pending error message that was never retrieved via OIIO::geterror(). This was the error message:\nCould not open file "D:\PhotosAndVideos\2024\Whale Watch\dng\_DHR9039.dng" What is the solution? |
My app is reading new files as them become available on disk. They may not be completely written when OIIO tries to read them. I have wrapped all my functions with
|
I don't think a support library should crash the program for any reason. There should be an error log created if an error is ignored and second is generated. If my app ignores errors, OIIO should not crash the app, IMHO. |
I completely agree. |
See #4400 for my attempt to address this:
-> should mean that a bad format won't crash the app. But you will get one of those unretrieved global error messages (if you didn't already retrieve it) that will clue us into a bad format call. In a debugger, if you set a breakpoint at the |
This error is format independent, but it was a DNG file as shown above in the error message. As I mentioned, I think this is a result of reading partially written DNG files. I have another app creating hundreds of DNG files and my app (Tinta) is monitoring the hard disk for files. When new file is detected, Tinta attempts to read it to display its thumbnail. I am assuming that the crash is caused because OIIO is given files by that are only partially created and causing repeated errors that I am not checking. |
Also, I have not been able to repro this failure in debug mode. I will set the breakpoint in release mode and provide an update soon. |
Have I misunderstood issue the whole time? The first post with the stack trace was of fmt itself hitting its internal assertion, which I thought could only happen in a case where fmt had a mismatched formatting string and arguments, or something of a similar nature. I thought we were chasing a bug in OIIO where we called some format function with incorrect arguments. I'm not sure how that would be connected to trying to open an incompete file, which I would think would fail its open(), issue an error of some kind, and then move on without having any reason to call assert_fail. So there may be a second bug somewhere in the mix, but I stand by that PR #4400 and its attempt to avoid any calls to std::terminate just because a fmt call gives bad arguments. You're right that exiting at that point would be an unhelpful behavior, independent of anything else we may need to track down. |
The overall issue is that when repeated oiio errors occur, the app is terminated. Thinking that OIIO shutdown by calling There are several things at play here.
It look suspicious to me that the thread_local function The error checking message is not the issue, there should just be an informational message printed. The issues as I see them are: A) Why is the call to
So my 'fix' works only because it is constantly reading and clearing the errors. This prevents the print message being issued in |
In |
The error holder itself is thread local. |
Yes, but is it possible for a different thread to modify the value of error_msg when the destructor is executing? |
When fmt arguments don't match the format string, fmt will throw an exception, or terminate if we disable exceptions (which we do). For gcc11+, we tried intercepting these, but let's do it for all platforms, and let's not terminate ourselves, but insted print and log the error. But, oof, to do this properly, I needed to move some error recording functionality from libOpenImageIO to libOpenImageIO_Util and make it owned more properly by strutil.cpp, so that this all works even when only using the util library. The logic isn't changing, it's just moving over to the other library. This all helps to address #4388 Unfortunately, the exception thrown by fmt doesn't tell us the bad format string itself. That would have really allowed to probably zero right in on it. But at least we know it's occurring, and one could put a breakpoint on pvt::log_fmt_error to catch it in the act and see where it's being called, revealing the bad line. Signed-off-by: Larry Gritz <[email protected]>
…tion#4400) When fmt arguments don't match the format string, fmt will throw an exception, or terminate if we disable exceptions (which we do). For gcc11+, we tried intercepting these, but let's do it for all platforms, and let's not terminate ourselves, but insted print and log the error. But, oof, to do this properly, I needed to move some error recording functionality from libOpenImageIO to libOpenImageIO_Util and make it owned more properly by strutil.cpp, so that this all works even when only using the util library. The logic isn't changing, it's just moving over to the other library. This all helps to address AcademySoftwareFoundation#4388 Unfortunately, the exception thrown by fmt doesn't tell us the bad format string itself. That would have really allowed to probably zero right in on it. But at least we know it's occurring, and one could put a breakpoint on pvt::log_fmt_error to catch it in the act and see where it's being called, revealing the bad line. Signed-off-by: Larry Gritz <[email protected]> Signed-off-by: Zach Lewis <[email protected]>
I keep getting assert_fail called in my app. I am using vcpkg, version 2.5.14.0
I don't have a complete stack track, just
Should I define FMT_THROW to something, so it will throw vs. crash? It is currently crashing my app.
I do not have a repro case, it occurs every 10 minutes or so in my app.
Windows 11
The text was updated successfully, but these errors were encountered: