conda-forge / cppyy-feedstock

A conda-smithy repository for cppyy.
BSD 3-Clause "New" or "Revised" License
3 stars 4 forks source link

Segfault on Linux x86_64 with cppyy==2.4.0 #63

Open qazi0 opened 2 years ago

qazi0 commented 2 years ago

Solution to issue cannot be found in the documentation.

Issue

Running

conda install -c conda-forge cppyy==2.4.0

on Linux x86_64 (Ubuntu 20.04 LTS) with conda 4.13.0 and then doing import cppyy results in a LONG error message that terminates in a segfault. I have already found out the issue and a fix for it - the detail of the environment plans, the error as well as my fix is here

But in summary: with a default conda install, even when we run conda install -c conda-forge cppyy on Linux x86_64, conda picks cppyy and cling from conda-forge but installs the gcc packages from pkgs/main (WHICH IT SHOULDN'T), which are not the same as conda-forge's GCC and for some reason don't work with Clang, running into a segfault. Here's a subsection of the conda package plan after running conda install -c conda-forge cppyy==2.4.0 showing the problematic GCC from pkgs/main instead of conda-forge:


  environment location: /anaconda/envs/fast

  added / updated specs:
    - cppyy==2.4.0

The following NEW packages will be INSTALLED:

  binutils_impl_lin~ pkgs/main/linux-64::binutils_impl_linux-64-2.38-h2a08ee3_1        <--- from pkgs/main instead of conda-forge
  binutils_linux-64  pkgs/main/linux-64::binutils_linux-64-2.38.0-hc2dff05_0
  cppyy              conda-forge/linux-64::cppyy-2.4.0-py39hd14de60_0
  cppyy-backend      conda-forge/linux-64::cppyy-backend-1.14.9-py39hf939315_0
  cppyy-cling        conda-forge/linux-64::cppyy-cling-6.27.0-py39h3d66fe8_1
  cpycppyy           conda-forge/linux-64::cpycppyy-1.12.11-py39hf939315_0
  cxx-compiler       conda-forge/linux-64::cxx-compiler-1.0.0-hf484d3e_0
  gcc_impl_linux-64  pkgs/main/linux-64::gcc_impl_linux-64-11.2.0-h1234567_1          <--- from pkgs/main instead of conda-forge
  gcc_linux-64       pkgs/main/linux-64::gcc_linux-64-11.2.0-h5c386dc_0
  gxx_impl_linux-64  pkgs/main/linux-64::gxx_impl_linux-64-11.2.0-h1234567_1
  gxx_linux-64       pkgs/main/linux-64::gxx_linux-64-11.2.0-hc2dff05_0
  kernel-headers_li~ conda-forge/noarch::kernel-headers_linux-64-2.6.32-he073ed8_15
  libgcc-devel_linu~ pkgs/main/linux-64::libgcc-devel_linux-64-11.2.0-h1234567_1
  libllvm9           conda-forge/linux-64::libllvm9-9.0.1-default_hc23dcda_7
  libstdcxx-devel_l~ pkgs/main/linux-64::libstdcxx-devel_linux-64-11.2.0-h1234567_1  <--- from pkgs/main instead of conda-forge
  libzlib            conda-forge/linux-64::libzlib-1.2.12-h166bdaf_3
  python_abi         conda-forge/linux-64::python_abi-3.9-2_cp39
  sysroot_linux-64   conda-forge/noarch::sysroot_linux-64-2.12-he073ed8_15

The fix

(see detail here) I created a ~/.condarc, and added this to it:

channels: [conda-forge]
pip_interop_enabled: true
channel_priority: strict

Then ran conda install -c conda-forge cppyy==2.4.0. This time it fetches all the packages (incl. GCC) correctly from conda-forge:

The following NEW packages will be INSTALLED:

  binutils_impl_lin~ conda-forge/linux-64::binutils_impl_linux-64-2.36.1-h193b22a_2
  binutils_linux-64  conda-forge/linux-64::binutils_linux-64-2.36-hf3e587d_10
  cppyy              conda-forge/linux-64::cppyy-2.4.0-py310h8a6ca7b_0
  cppyy-backend      conda-forge/linux-64::cppyy-backend-1.14.9-py310hbf28c38_0
  cppyy-cling        conda-forge/linux-64::cppyy-cling-6.27.0-py310hd64a29c_0
  cpycppyy           conda-forge/linux-64::cpycppyy-1.12.11-py310hbf28c38_0
  gcc_impl_linux-64  conda-forge/linux-64::gcc_impl_linux-64-10.4.0-h7ee1905_16
  gcc_linux-64       conda-forge/linux-64::gcc_linux-64-10.4.0-h9215b83_10
  gxx_impl_linux-64  conda-forge/linux-64::gxx_impl_linux-64-10.4.0-h7ee1905_16
  gxx_linux-64       conda-forge/linux-64::gxx_linux-64-10.4.0-h6e491c6_10
  kernel-headers_li~ conda-forge/noarch::kernel-headers_linux-64-2.6.32-he073ed8_15
  libgcc-devel_linu~ conda-forge/linux-64::libgcc-devel_linux-64-10.4.0-h74af60c_16
  libllvm9           conda-forge/linux-64::libllvm9-9.0.1-default_hc23dcda_7
  libnsl             conda-forge/linux-64::libnsl-2.0.0-h7f98852_0
  libsanitizer       conda-forge/linux-64::libsanitizer-10.4.0-hde28e3b_16
  libsqlite          conda-forge/linux-64::libsqlite-3.39.3-h753d276_0
  libstdcxx-devel_l~ conda-forge/linux-64::libstdcxx-devel_linux-64-10.4.0-h74af60c_16

and thus doesn't segfault anymore.

Installed packages

Please see https://github.com/wlav/cppyy/issues/97#issuecomment-1255049719 for complete details, I'm writing this issue from my Mac M1 (which doesn't have this bug in conda), my referenced GitHub comment link contains all the environment info, os info, python version, cppyy info, cppyy interpreter (..ProcessLine('__cplusplus')) and everything else you'd need. Please feel free to ask for any more details, though I believe this error is very easily reproduceable. I even created a fresh new Azure Ubuntu 20.04 Linux x86_64 VM, downloaded the latest Ananconda-2022.05 (x86_64), created a new python3.9 environment and ran conda install -c conda-forge cppyy, still ran into this issue.

Environment and version info

Please see https://github.com/wlav/cppyy/issues/97#issuecomment-1255049719 and above description.

OS & Platform

❯ uname -a
Linux siraj-compute 5.15.0-1017-azure #20~20.04.1-Ubuntu SMP x86_64 GNU/Linux

Python

❯ python --version
Python 3.9.13

Anaconda

❯ conda --version
conda 4.13.0

cppyy

❯ pip list | grep cppyy
cppyy         2.4.0
cppyy-backend 1.14.9
cppyy-cling   6.27.0

cppyy installed with:

conda create -n fast python=3.9
conda activate fast
conda install -c conda-forge cppyy==2.4.0

cppyy C++ version:

>>> cppyy.gbl.gInterpreter.ProcessLine('__cplusplus')
(long) 201703
201703