Skip to content

Addressing OpenEXRCore Symbol Conflicts When Using Multiple OpenEXR Versions in the same app #2197

@vlazar-ilm

Description

@vlazar-ilm

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:

  1. 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_run would become INTERNAL_EXR1_exr_encoding_run.
    • Downside is that it's a fairly intrusive change
    • Would work on all platforms
  2. Symbol Versioning (Linux)

    • On Linux, we could use symbol versioning, similar to how glibc manages 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.

Any fresh insight on this issue is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions