Skip to content

import chdb after import ray aborts with 'free(): invalid pointer' on Linux #571

@wudidapaopao

Description

@wudidapaopao

Reproduction

pip install chdb ray
python -c 'import ray; import chdb; print("ok")'

Result on Linux:

free(): invalid pointer
IOT instruction (core dumped)

Exit code 134 (SIGABRT). Reversing the import order (import chdb; import ray) works.

Cause

_chdb.abi3.so (linked against libc++) and ray._raylet.so (linked against libstdc++) both expose weak C++ runtime symbols (operator new / operator delete / std::string internals). When ray loads first, its libstdc++ wins the global symbol slot; chdb's later allocations and frees then cross allocator boundaries and corrupt the heap.

chdb-core 26.3.0 ships a RTLD_DEEPBIND preload in its own chdb/__init__.py that isolates chdb's symbol scope. But the chdb wrapper wheel also ships a chdb/__init__.py, which pip installs second and overwrites chdb-core's version — the preload never runs in real installs.

Fix

Mirror the same RTLD_DEEPBIND preload into the chdb wrapper's __init__.py so it survives the install-time overwrite.

Environment

  • chdb 4.1.7, chdb-core 26.3.0, ray 2.55.1
  • Linux x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions