salilab / imp

The Integrative Modeling Platform
https://integrativemodeling.org
GNU General Public License v3.0
74 stars 30 forks source link

Segfaults trying to print Hierarchy objects with conda package on Mac #1062

Closed benmwebb closed 2 years ago

benmwebb commented 2 years ago

@Pellarin reports that the pol3 tutorial at https://github.com/Pellarin/imp_tutorial_pol3 segfaults when trying to build the initial PMI hierarchy. This is with IMP 2.17.0 and Python 3.10 on a Mac, using the conda package.

I can confirm this on my Mac:

% conda create --name imp_py310 python=3.10 imp matplotlib
% conda activate imp_py310
% git clone https://github.com/Pellarin/imp_tutorial_pol3.git
% cd imp_tutorial_pol3/rnapoliii/modeling
% python test.py
...
zsh: segmentation fault  python test.py

The segfault is being raised when trying to print the Hierarchy object created by IMP.pmi.topology.Molecule.build(): https://github.com/salilab/pmi/blob/195b5193a3/pyext/src/topology/__init__.py#L868

Same thing happens for conda with Python 3.9, although the Homebrew package (also with Python 3.9) works fine on the same machine.

benmwebb commented 2 years ago

Actually the conda package fails trying to print any Hierarchy object, e.g. trying to run the test_xyz_show test in IMP.atom's test_hierarchy.py, at https://github.com/salilab/imp/blob/2.17.0/modules/atom/test/test_hierarchy.py#L128-L136, also fails:

import IMP.atom, IMP.core, IMP.algebra
m = IMP.Model()
p = IMP.Particle(m)
xyz = IMP.core.XYZ.setup_particle(p, IMP.algebra.Vector3D(1,2,3))
h = IMP.atom.Hierarchy(p)
print(h)

This is regularly tested of course on all platforms so must be something specific to the conda environment (e.g. libraries, compiler) and will need to be worked around (and tested for) in the conda package, conda-forge/imp-feedstock.

benmwebb commented 2 years ago

This looks to be a mismatch between the conda-provided libc++.1.dylib and that as part of with the operating system. (The Homebrew package works because Homebrew uses the OS-provided libraries, so no mismatch can occur.) This is similar to conda-forge/libcxx-feedstock#77 and can be fixed by not building our Python extensions with -flat_namespace. I'll fix this in main and open a PR with conda-forge to patch the 2.17.0 release.