decord icon indicating copy to clipboard operation
decord copied to clipboard

RTLD_GLOBAL causes symbol conflicts with other libraries

Open claydugo opened this issue 5 months ago • 0 comments

Problem

Decord uses ctypes.RTLD_GLOBAL when loading libdecord.so, which exports all symbols (including FFmpeg/libav) into the global namespace. This causes symbol conflicts with other libraries that use similar dependencies, leading to crashes.

Minimal Reproduction

import decord
import wgpu

adapter = wgpu.gpu.request_adapter_sync()
Segmentation fault (core dumped)

Expected behavior: Both libraries work together without crashes.

Root Cause

The issue is in python/decord/_ffi/base.py:39:

def _load_lib():
    """Load libary by searching possible path."""
    lib_path = libinfo.find_lib_path()
    os.environ['PATH'] += os.pathsep + os.path.dirname(lib_path[0])
    lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)  # <---
    # DMatrix functions
    lib.DECORDGetLastError.restype = ctypes.c_char_p
    return lib, os.path.basename(lib_path[0])

Additional Context

  • Platform: Linux
  • Python: 3.13
  • Decord: Latest from pip
  • Other library tested: wgpu

claydugo avatar Nov 21 '25 22:11 claydugo