{"record":{"id":"1dce3da3e48cfeee","repo":"xai-org/x-algorithm","slug":"could-not-resolve-loaded-nccl-library-path","errorCode":null,"errorMessage":"could not resolve loaded NCCL library path","messagePattern":"could not resolve loaded NCCL library path","errorType":"exception","errorClass":"std::runtime_error","httpStatus":null,"severity":"warning","filePath":"phoenix/xrex/cuda/async_emb/src/async_emb_api.cc","lineNumber":840,"sourceCode":"          throw std::invalid_argument(\"async_emb context not initialized\");\n        }\n        ctx->resetTableBinding();\n      },\n      nb::call_guard<nb::gil_scoped_release>()\n  );\n  m.def(\"_test_snapshot\", &testSnapshot);\n  m.def(\"nccl_version\", [] {\n    int version = 0;\n    ncclResult_t result = ncclGetVersion(&version);\n    if (result != ncclSuccess) {\n      throw std::runtime_error(ncclGetErrorString(result));\n    }\n    return version;\n  });\n  m.def(\"nccl_library_path\", [] {\n    Dl_info info{};\n    if (dladdr(reinterpret_cast<void*>(&ncclGetVersion), &info) == 0 || info.dli_fname == nullptr) {\n      throw std::runtime_error(\"could not resolve loaded NCCL library path\");\n    }\n    return std::string(info.dli_fname);\n  });\n}\n\n}\n","sourceCodeStart":822,"sourceCodeEnd":847,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/cuda/async_emb/src/async_emb_api.cc#L822-L847","documentation":"The nccl_library_path binding uses dladdr on ncclGetVersion to find the loaded NCCL shared object path. If dladdr fails (returns 0) or yields a null filename, a std::runtime_error 'could not resolve loaded NCCL library path' is thrown.","triggerScenarios":"Calling async_emb.nccl_library_path() when the NCCL symbols cannot be mapped back to a loaded DSO — e.g. statically linked NCCL, symbols resolved via a shim/trampoline, or unusual loader setups where dladdr info is unavailable.","commonSituations":"Static NCCL linkage in custom builds; LD_PRELOAD interposition of NCCL symbols; stripped or unusual ELF setups; calling in restricted sandbox environments where dladdr info is limited.","solutions":["Fall back to inspecting /proc/self/maps (or ldd on the module .so) to find the NCCL DSO manually","Avoid preloads/shims that hide NCCL symbol provenance","If NCCL is statically linked, expect this to fail and use build metadata instead"],"exampleFix":"# before\npath = async_emb.nccl_library_path()  # throws if dladdr fails\n\n# after\nimport subprocess\npath = next(l for l in open('/proc/self/maps') if 'libnccl' in l).split()[-1]","handlingStrategy":"fallback","validationCode":"def ncclPath():\n    try:\n        return async_emb.nccl_library_path()\n    except RuntimeError:\n        return next((l.split()[-1] for l in open('/proc/self/maps') if 'libnccl' in l), None)","typeGuard":null,"tryCatchPattern":"try:\n    path = async_emb.nccl_library_path()\nexcept RuntimeError as e:\n    path = next((l.split()[-1] for l in open('/proc/self/maps') if 'libnccl' in l), None)\n    if path is None: raise","preventionTips":["Don't interpose NCCL symbols via LD_PRELOAD in diagnostics flows","Keep a /proc/self/maps fallback for DSO discovery"],"tags":["async-emb","cpp","nccl","diagnostics","environment"],"backgroundTag":"shared-library-resolution-failed","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}