-
Notifications
You must be signed in to change notification settings - Fork 659
Description
Hello,
I've identified a problem when trying to use multiple versions of OpenEXR side-by-side in the same application.
The Problem
While the OpenEXR C++ API successfully avoids conflicts using its custom namespace feature, this protection does not extend to the C-based OpenEXRCore library.
When using dynamic libraries, the OpenEXR C++ library depends on OpenEXRCore. The dynamic linker resolves symbols for OpenEXRCore only once. This means that if multiple versions of OpenEXR are loaded, they will all incorrectly link against the first OpenEXRCore library that was loaded. This "symbol cross-talk" can lead to crashes or undefined behavior when a C++ library calls a C function from the wrong version of Core.
Proposed Solutions
To properly support side-by-side versioning, the C symbols in OpenEXRCore must also be uniquely identified. I thought about two potential solutions for this:
-
Opt-In C Symbol Prefixing
- This approach would mirror the C++ custom namespace feature.
- This would be an opt-in feature, allowing developers to ensure their custom builds do not conflict with other versions, while official builds will remain compatible with public builds
- A new compile-time prefix would be added to all public facing C symbols.
- Example:
exr_encoding_runwould becomeINTERNAL_EXR1_exr_encoding_run. - Downside is that it's a fairly intrusive change
- Would work on all platforms
-
Symbol Versioning (Linux)
- On Linux, we could use symbol versioning, similar to how
glibcmanages compatibility. - The official OpenEXR build could use a stable version (e.g.,
OPENEXR_1.0), and custom builds could use their own unique version string. - This would create a "hard link" binding each OpenEXR C++ library to its specific OpenEXRCore version.
- Caveat: I am unsure of the intricacies or equivalents of this method on Windows and macOS dynamic linkers.
- On Linux, we could use symbol versioning, similar to how
Any fresh insight on this issue is appreciated.