openexr
openexr copied to clipboard
ImfErrorMessage C Api and multithreading
The ImfErrorMessage
method uses a shared buffer errorMessage
and this could result in an incorrect error messages when multiple images copy an exception message into that same errorbuffer. Would it be possible to make some changes to make the error message file specific?
An option would be to "attach" the error message to the ImfInputFile
struct but that will not work for the ImfOpenInputFile
method. Maybe a new method could be used to store "something" on the ImfInputFile
that would store an error message. Maybe something like this:
ImfContext *context;
ImfInputFile *file;
const char *error_message;
context=ImfContextOpenInputFile(filename);
file=ImfContextGetInputFile(context);
error_message=ImfContextErrorMessage(context);
ImfContextClose(context);
This approach would prevent breaking changes to the C API but would allow having an error message per image.
Thanks for pointing this out.
Just fyi, this will all get revamped slightly when we switch the C++ api to use the new C core library, and then the "friendly" C api will get similar updates. In the core library, each file is a "context" where you can set error handlers, memory allocators, the like, and so the only stateful things are the global defaults for things which are used to initialize a context if you don't set the values.
Closing this now because it seems that this has been addressed in the new C api.