Skip to content

RTLD_GLOBAL causes symbol conflicts with other libraries #361

@claydugo

Description

@claydugo

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

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