conda-forge / ctng-compiler-activation-feedstock

A conda-smithy repository for ctng-compiler-activation.
BSD 3-Clause "New" or "Revised" License
13 stars 22 forks source link

Segfault when mixing bob.blitz and tensorflow #57

Closed 183amir closed 2 years ago

183amir commented 2 years ago

Issue: I am trying to fix a segmentation fault (core dump) when importing my package before tensorflow. This is how the error happens:

$ python -c "import bob.blitz, tensorflow"
free(): invalid pointer
[1]    23231 IOT instruction (core dumped)  python -c "import bob.blitz, tensorflow"

but this error does not happen when I do:

$ python -c "import tensorflow, bob.blitz"

or when I do:

$ LD_PRELOAD=/lib64/libstdc++.so.6 bin/python -c "import bob.blitz, tensorflow"

and here is what I get from my env:

ldd -d bob/blitz/_library.cpython-38-x86_64-linux-gnu.so
    linux-vdso.so.1 (0x00007fff82732000)
    libblitz.so.0 => /home/amir/miniconda/envs/blitz/lib/libblitz.so.0 (0x00007f8bb87cc000)
    libstdc++.so.6 => /home/amir/miniconda/envs/blitz/lib/libstdc++.so.6 (0x00007f8bb8621000)
    libgcc_s.so.1 => /home/amir/miniconda/envs/blitz/lib/libgcc_s.so.1 (0x00007f8bb860c000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8bb85d5000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f8bb8406000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f8bb82c0000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f8bb8ab4000)
ldd -d ~/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/libtensorflow_framework.so.2 | grep libstd
    libstdc++.so.6 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../../libstdc++.so.6 (0x00007fba6ee92000)
ldd -d ~/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/libtensorflow_framework.so.2              
    linux-vdso.so.1 (0x00007ffcca0f2000)
    libcurl.so.4 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../../libcurl.so.4 (0x00007ff4f9fa3000)
    libcrypto.so.1.1 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../../libcrypto.so.1.1 (0x00007ff4f9cd7000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007ff4f9cba000)
    libm.so.6 => /lib64/libm.so.6 (0x00007ff4f9b76000)
    libsnappy.so.1 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../../libsnappy.so.1 (0x00007ff4f9b6b000)
    libprotobuf.so.26 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../../libprotobuf.so.26 (0x00007ff4f98ba000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff4f9899000)
    libgif.so.7 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../../libgif.so.7 (0x00007ff4f988a000)
    libjpeg.so.9 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../../libjpeg.so.9 (0x00007ff4f984c000)
    libz.so.1 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../../libz.so.1 (0x00007ff4f9832000)
    libstdc++.so.6 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../../libstdc++.so.6 (0x00007ff4f9685000)
    librt.so.1 => /lib64/librt.so.1 (0x00007ff4f967a000)
    libgcc_s.so.1 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../../libgcc_s.so.1 (0x00007ff4f9665000)
    libc.so.6 => /lib64/libc.so.6 (0x00007ff4f9496000)
    /lib64/ld-linux-x86-64.so.2 (0x00007ff4fb0b0000)
    libnghttp2.so.14 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../.././libnghttp2.so.14 (0x00007ff4f946d000)
    libssh2.so.1 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../.././libssh2.so.1 (0x00007ff4f9429000)
    libssl.so.1.1 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../.././libssl.so.1.1 (0x00007ff4f9396000)
    libgssapi_krb5.so.2 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../.././libgssapi_krb5.so.2 (0x00007ff4f9343000)
    libkrb5.so.3 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../.././libkrb5.so.3 (0x00007ff4f926f000)
    libk5crypto.so.3 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../.././libk5crypto.so.3 (0x00007ff4f9255000)
    libcom_err.so.3 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../.././libcom_err.so.3 (0x00007ff4f924f000)
    libkrb5support.so.0 => /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/tensorflow/../../../././libkrb5support.so.0 (0x00007ff4f923e000)
    libresolv.so.2 => /lib64/libresolv.so.2 (0x00007ff4f9224000)

So my question is why does adding LD_PRELOAD=/lib64/libstdc++.so.6 fixe my issue? even though it looks like the packages are linked correctly. I will post instructions to reproduce this issue soon.


Environment (conda list):

``` $ conda list # packages in environment at /home/amir/miniconda/envs/blitz: # # Name Version Build Channel _libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 1_gnu conda-forge abseil-cpp 20210324.2 h9c3ff4c_0 conda-forge absl-py 0.14.1 pyhd8ed1ab_0 conda-forge aiohttp 3.7.4.post0 py38h497a2fe_0 conda-forge alabaster 0.7.12 py_0 conda-forge alsa-lib 1.2.3 h516909a_0 conda-forge appdirs 1.4.4 pyh9f0ad1d_0 conda-forge argon2-cffi 21.1.0 py38h497a2fe_0 conda-forge astor 0.8.1 pyh9f0ad1d_0 conda-forge astunparse 1.6.3 pyhd8ed1ab_0 conda-forge async-timeout 3.0.1 py_1000 conda-forge async_generator 1.10 py_0 conda-forge attrs 21.2.0 pyhd8ed1ab_0 conda-forge babel 2.9.1 pyh44b312d_0 conda-forge backcall 0.2.0 pyh9f0ad1d_0 conda-forge backports 1.0 py_2 conda-forge backports.functools_lru_cache 1.6.4 pyhd8ed1ab_0 conda-forge binutils 2.36.1 hdd6e379_2 conda-forge binutils_impl_linux-64 2.36.1 h193b22a_2 conda-forge binutils_linux-64 2.36 hf3e587d_1 conda-forge bleach 4.1.0 pyhd8ed1ab_0 conda-forge blinker 1.4 py_1 conda-forge blosc 1.21.0 h9c3ff4c_0 conda-forge bob-buildout 2.3.0 pypi_0 pypi bob.extension 6.1.1b0 py38h6434a95_3 http://www.idiap.ch/software/bob/conda/label/beta bokeh 2.3.3 py38h578d9bd_0 conda-forge boost 1.76.0 py38hfc89cab_0 conda-forge boost-cpp 1.76.0 h312852a_1 conda-forge brotli 1.0.9 h7f98852_5 conda-forge brotli-bin 1.0.9 h7f98852_5 conda-forge brotlipy 0.7.0 py38h497a2fe_1001 conda-forge brunsli 0.1 h9c3ff4c_0 conda-forge bzip2 1.0.8 h7f98852_4 conda-forge c-ares 1.17.2 h7f98852_0 conda-forge c-compiler 1.3.0 h7f98852_0 conda-forge ca-certificates 2021.10.8 ha878542_0 conda-forge cachetools 4.2.4 pyhd8ed1ab_0 conda-forge caiman 1.9.3 py38h43a58ef_0 conda-forge cairo 1.16.0 h6cf1ce9_1008 conda-forge certifi 2021.10.8 py38h578d9bd_0 conda-forge cffi 1.14.6 py38h3931269_1 conda-forge cfitsio 3.470 hb418390_7 conda-forge chardet 4.0.0 py38h578d9bd_1 conda-forge charls 2.2.0 h9c3ff4c_0 conda-forge charset-normalizer 2.0.0 pyhd8ed1ab_0 conda-forge click 8.0.3 py38h578d9bd_0 conda-forge click-plugins 1.1.1 py_0 conda-forge cloudpickle 2.0.0 pyhd8ed1ab_0 conda-forge cmake 3.21.3 h8897547_0 conda-forge colorama 0.4.4 pyh9f0ad1d_0 conda-forge colorcet 2.0.6 pyhd8ed1ab_0 conda-forge compilers 1.3.0 ha770c72_0 conda-forge coverage 6.0.2 py38h497a2fe_0 conda-forge cryptography 3.4.8 py38ha5dfef3_0 conda-forge cxx-compiler 1.3.0 h4bd325d_0 conda-forge cycler 0.10.0 py_2 conda-forge cytoolz 0.11.0 py38h497a2fe_3 conda-forge dask-core 2021.9.1 pyhd8ed1ab_0 conda-forge dataclasses 0.8 pyhc8e2a94_3 conda-forge dbus 1.13.6 h48d8840_2 conda-forge debugpy 1.4.1 py38h709712a_0 conda-forge decorator 5.1.0 pyhd8ed1ab_0 conda-forge defusedxml 0.7.1 pyhd8ed1ab_0 conda-forge docutils 0.17.1 py38h578d9bd_0 conda-forge entrypoints 0.3 py38h32f6830_1002 conda-forge expat 2.4.1 h9c3ff4c_0 conda-forge ffmpeg 4.3.2 hca11adc_0 conda-forge fontconfig 2.13.1 hba837de_1005 conda-forge fortran-compiler 1.3.0 h1990efc_0 conda-forge freetype 2.10.4 h0708190_1 conda-forge fsspec 2021.10.0 pyhd8ed1ab_0 conda-forge future 0.18.2 py38h578d9bd_3 conda-forge gast 0.3.3 py_0 conda-forge gcc 9.4.0 h192d537_1 conda-forge gcc_impl_linux-64 9.4.0 h03d3576_10 conda-forge gcc_linux-64 9.4.0 h391b98a_1 conda-forge gettext 0.19.8.1 h73d1719_1008 conda-forge gfortran 9.4.0 h2018a41_1 conda-forge gfortran_impl_linux-64 9.4.0 h0003116_10 conda-forge gfortran_linux-64 9.4.0 hf0ab688_1 conda-forge giflib 5.2.1 h36c2ea0_2 conda-forge glib 2.68.4 h9c3ff4c_1 conda-forge glib-tools 2.68.4 h9c3ff4c_1 conda-forge gmp 6.2.1 h58526e2_0 conda-forge gnutls 3.6.13 h85f3911_1 conda-forge google-auth 1.35.0 pyh6c4a22f_0 conda-forge google-auth-oauthlib 0.4.6 pyhd8ed1ab_0 conda-forge google-pasta 0.2.0 pyh8c360ce_0 conda-forge graphite2 1.3.13 h58526e2_1001 conda-forge grpc-cpp 1.37.1 hfc4d69e_3 conda-forge grpcio 1.37.1 py38hdd6454d_0 conda-forge gst-plugins-base 1.18.5 hf529b03_0 conda-forge gstreamer 1.18.5 h76c114f_0 conda-forge gxx 9.4.0 h192d537_1 conda-forge gxx_impl_linux-64 9.4.0 h03d3576_10 conda-forge gxx_linux-64 9.4.0 h0316aca_1 conda-forge h5py 2.10.0 nompi_py38h9915d05_106 conda-forge harfbuzz 2.9.1 h83ec7ef_1 conda-forge hdf5 1.10.6 nompi_h6a2412b_1114 conda-forge hdmf 2.2.0 pyh9f0ad1d_0 conda-forge holoviews 1.14.6 pyhd8ed1ab_0 conda-forge icu 68.1 h58526e2_0 conda-forge idna 3.1 pyhd3deb0d_0 conda-forge imagecodecs 2021.7.30 py38hb5ce8f7_1 conda-forge imageio 2.9.0 py_0 conda-forge imagesize 1.2.0 py_0 conda-forge importlib-metadata 4.8.1 py38h578d9bd_0 conda-forge ipdb 0.13.9 pypi_0 pypi ipdbplugin 1.5.0 pypi_0 pypi ipykernel 6.4.1 py38he5a9106_0 conda-forge ipyparallel 7.1.0 pyhd8ed1ab_0 conda-forge ipython 7.28.0 py38he5a9106_0 conda-forge ipython_genutils 0.2.0 py_1 conda-forge ipywidgets 7.6.5 pyhd8ed1ab_0 conda-forge jasper 1.900.1 h07fcdf6_1006 conda-forge jbig 2.1 h7f98852_2003 conda-forge jedi 0.18.0 py38h578d9bd_2 conda-forge jinja2 3.0.2 pyhd8ed1ab_0 conda-forge joblib 1.1.0 pyhd8ed1ab_0 conda-forge jpeg 9d h36c2ea0_0 conda-forge jsonschema 4.1.0 pyhd8ed1ab_0 conda-forge jupyter 1.0.0 py38h578d9bd_6 conda-forge jupyter_client 7.0.6 pyhd8ed1ab_0 conda-forge jupyter_console 6.4.0 pyhd8ed1ab_0 conda-forge jupyter_core 4.8.1 py38h578d9bd_0 conda-forge jupyterlab_pygments 0.1.2 pyh9f0ad1d_0 conda-forge jupyterlab_widgets 1.0.2 pyhd8ed1ab_0 conda-forge jxrlib 1.1 h7f98852_2 conda-forge keras-preprocessing 1.1.2 pyhd8ed1ab_0 conda-forge kernel-headers_linux-64 2.6.32 he073ed8_14 conda-forge kiwisolver 1.3.2 py38h1fd1430_0 conda-forge krb5 1.19.2 hcc1bbae_2 conda-forge lame 3.100 h7f98852_1001 conda-forge lcms2 2.12 hddcbb42_0 conda-forge ld_impl_linux-64 2.36.1 hea4e1c9_2 conda-forge lerc 2.2.1 h9c3ff4c_0 conda-forge libaec 1.0.6 h9c3ff4c_0 conda-forge libblas 3.9.0 11_linux64_openblas conda-forge libblitz 1.0.2 h9c3ff4c_2 conda-forge libbrotlicommon 1.0.9 h7f98852_5 conda-forge libbrotlidec 1.0.9 h7f98852_5 conda-forge libbrotlienc 1.0.9 h7f98852_5 conda-forge libcblas 3.9.0 11_linux64_openblas conda-forge libclang 11.1.0 default_ha53f305_1 conda-forge libcurl 7.79.1 h2574ce0_1 conda-forge libdeflate 1.7 h7f98852_5 conda-forge libedit 3.1.20191231 he28a2e2_2 conda-forge libev 4.33 h516909a_1 conda-forge libevent 2.1.10 h9b69904_4 conda-forge libffi 3.4.2 h9c3ff4c_4 conda-forge libgcc-devel_linux-64 9.4.0 hd854feb_10 conda-forge libgcc-ng 11.2.0 h1d223b6_10 conda-forge libgfortran-ng 11.2.0 h69a702a_10 conda-forge libgfortran5 11.2.0 h5c6108e_10 conda-forge libglib 2.68.4 h174f98d_1 conda-forge libgomp 11.2.0 h1d223b6_10 conda-forge libiconv 1.16 h516909a_0 conda-forge liblapack 3.9.0 11_linux64_openblas conda-forge liblapacke 3.9.0 11_linux64_openblas conda-forge libllvm11 11.1.0 hf817b99_2 conda-forge libnghttp2 1.43.0 h812cca2_1 conda-forge libogg 1.3.4 h7f98852_1 conda-forge libopenblas 0.3.17 pthreads_h8fe5266_1 conda-forge libopencv 4.5.2 py38hcdf9bf1_0 conda-forge libopus 1.3.1 h7f98852_1 conda-forge libpng 1.6.37 h21135ba_2 conda-forge libpq 13.3 hd57d9b9_1 conda-forge libprotobuf 3.15.8 h780b84a_1 conda-forge libsanitizer 9.4.0 h79bfe98_10 conda-forge libsodium 1.0.18 h36c2ea0_1 conda-forge libssh2 1.10.0 ha56f1ee_2 conda-forge libstdcxx-devel_linux-64 9.4.0 hd854feb_10 conda-forge libstdcxx-ng 11.2.0 he4da1e4_10 conda-forge libtiff 4.3.0 hf544144_1 conda-forge libuuid 2.32.1 h7f98852_1000 conda-forge libuv 1.42.0 h7f98852_0 conda-forge libvorbis 1.3.7 h9c3ff4c_0 conda-forge libwebp-base 1.2.1 h7f98852_0 conda-forge libxcb 1.13 h7f98852_1003 conda-forge libxkbcommon 1.0.3 he3ba5ed_0 conda-forge libxml2 2.9.12 h72842e0_0 conda-forge libzlib 1.2.11 h36c2ea0_1013 conda-forge libzopfli 1.0.3 h9c3ff4c_0 conda-forge locket 0.2.0 py_2 conda-forge lz4-c 1.9.3 h9c3ff4c_1 conda-forge make 4.3 hd18ef5c_1 conda-forge markdown 3.3.4 pyhd8ed1ab_0 conda-forge markupsafe 2.0.1 py38h497a2fe_0 conda-forge matplotlib 3.4.3 py38h578d9bd_1 conda-forge matplotlib-base 3.4.3 py38hf4fb855_1 conda-forge matplotlib-inline 0.1.3 pyhd8ed1ab_0 conda-forge mistune 0.8.4 py38h497a2fe_1004 conda-forge mr-developer 2.0.1 pypi_0 pypi multidict 5.2.0 py38h497a2fe_0 conda-forge mypy 0.910 py38h497a2fe_0 conda-forge mypy_extensions 0.4.3 py38h578d9bd_3 conda-forge mysql-common 8.0.25 ha770c72_2 conda-forge mysql-libs 8.0.25 hfa10184_2 conda-forge nbclient 0.5.4 pyhd8ed1ab_0 conda-forge nbconvert 6.2.0 py38h578d9bd_0 conda-forge nbformat 5.1.3 pyhd8ed1ab_0 conda-forge ncurses 6.2 h58526e2_4 conda-forge nest-asyncio 1.5.1 pyhd8ed1ab_0 conda-forge nettle 3.6 he412f7d_0 conda-forge networkx 2.5 py_0 conda-forge nose 1.3.7 py38h32f6830_1004 conda-forge notebook 6.4.4 pyha770c72_0 conda-forge nspr 4.30 h9c3ff4c_0 conda-forge nss 3.69 hb5efdd6_1 conda-forge numpy 1.21.2 py38he2449b9_0 conda-forge oauthlib 3.1.1 pyhd8ed1ab_0 conda-forge olefile 0.46 pyh9f0ad1d_1 conda-forge opencv 4.5.2 py38h578d9bd_0 conda-forge openh264 2.1.1 h780b84a_0 conda-forge openjpeg 2.4.0 hb52868f_1 conda-forge openssl 1.1.1l h7f98852_0 conda-forge opt_einsum 3.3.0 pyhd8ed1ab_1 conda-forge packaging 21.0 pyhd8ed1ab_0 conda-forge pandas 1.3.3 py38h43a58ef_0 conda-forge pandoc 2.14.2 h7f98852_0 conda-forge pandocfilters 1.5.0 pyhd8ed1ab_0 conda-forge panel 0.12.1 pyhd8ed1ab_0 conda-forge param 1.11.1 pyh6c4a22f_0 conda-forge parso 0.8.2 pyhd8ed1ab_0 conda-forge partd 1.2.0 pyhd8ed1ab_0 conda-forge pcre 8.45 h9c3ff4c_0 conda-forge peakutils 1.3.3 py_0 conda-forge pexpect 4.8.0 py38h32f6830_1 conda-forge pickleshare 0.7.5 py38h32f6830_1002 conda-forge pillow 8.3.2 py38h8e6f84c_0 conda-forge pims 0.5 pyh9f0ad1d_1 conda-forge pip 21.3 pyhd8ed1ab_0 conda-forge pixman 0.40.0 h36c2ea0_0 conda-forge pkg-config 0.29.2 h36c2ea0_1008 conda-forge pooch 1.5.2 pyhd8ed1ab_0 conda-forge prometheus_client 0.11.0 pyhd8ed1ab_0 conda-forge prompt-toolkit 3.0.20 pyha770c72_0 conda-forge prompt_toolkit 3.0.20 hd8ed1ab_0 conda-forge protobuf 3.15.8 py38h709712a_0 conda-forge psutil 5.8.0 py38h497a2fe_1 conda-forge pthread-stubs 0.4 h36c2ea0_1001 conda-forge ptyprocess 0.7.0 pyhd3deb0d_0 conda-forge py-opencv 4.5.2 py38hd0cf306_0 conda-forge pyasn1 0.4.8 py_0 conda-forge pyasn1-modules 0.2.7 py_0 conda-forge pycparser 2.20 pyh9f0ad1d_2 conda-forge pyct 0.4.6 py_0 conda-forge pyct-core 0.4.6 py_0 conda-forge pygments 2.10.0 pyhd8ed1ab_0 conda-forge pyjwt 2.2.0 pyhd8ed1ab_0 conda-forge pynwb 1.4.0 py38h578d9bd_1 conda-forge pyopenssl 21.0.0 pyhd8ed1ab_0 conda-forge pyparsing 2.4.7 pyh9f0ad1d_0 conda-forge pyqt 5.12.3 py38h578d9bd_7 conda-forge pyqt-impl 5.12.3 py38h7400c14_7 conda-forge pyqt5-sip 4.19.18 py38h709712a_7 conda-forge pyqtchart 5.12 py38h7400c14_7 conda-forge pyqtgraph 0.12.3 pyhd8ed1ab_0 conda-forge pyqtwebengine 5.12.1 py38h7400c14_7 conda-forge pyrsistent 0.17.3 py38h497a2fe_2 conda-forge pysocks 1.7.1 py38h578d9bd_3 conda-forge python 3.8.12 hb7a2778_1_cpython conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python-flatbuffers 1.12 pyhd8ed1ab_1 conda-forge python_abi 3.8 2_cp38 conda-forge pytz 2021.3 pyhd8ed1ab_0 conda-forge pyu2f 0.1.5 pyhd8ed1ab_0 conda-forge pyviz_comms 2.1.0 pyhd8ed1ab_0 conda-forge pywavelets 1.1.1 py38h6c62de6_3 conda-forge pyyaml 5.4.1 py38h497a2fe_1 conda-forge pyzmq 22.3.0 py38h2035c66_0 conda-forge qt 5.12.9 hda022c4_4 conda-forge qtconsole 5.1.1 pyhd8ed1ab_0 conda-forge qtpy 1.11.2 pyhd8ed1ab_0 conda-forge re2 2021.08.01 h9c3ff4c_0 conda-forge readline 8.1 h46c0cb4_0 conda-forge requests 2.26.0 pyhd8ed1ab_0 conda-forge requests-oauthlib 1.3.0 pyh9f0ad1d_0 conda-forge rhash 1.4.1 h7f98852_0 conda-forge rsa 4.7.2 pyh44b312d_0 conda-forge ruamel.yaml 0.17.16 py38h497a2fe_0 conda-forge ruamel.yaml.clib 0.2.2 py38h497a2fe_2 conda-forge scikit-image 0.18.3 py38h43a58ef_0 conda-forge scikit-learn 1.0 py38hacb3eff_1 conda-forge scipy 1.7.1 py38h56a6a73_0 conda-forge send2trash 1.8.0 pyhd8ed1ab_0 conda-forge setuptools 51.3.3 pypi_0 pypi six 1.15.0 pyh9f0ad1d_0 conda-forge slicerator 1.0.0 py_0 conda-forge snappy 1.1.8 he1b5a44_3 conda-forge snowballstemmer 2.1.0 pyhd8ed1ab_0 conda-forge sphinx 4.2.0 pyh6c4a22f_0 conda-forge sphinx_rtd_theme 1.0.0 pyhd8ed1ab_0 conda-forge sphinxcontrib-applehelp 1.0.2 py_0 conda-forge sphinxcontrib-devhelp 1.0.2 py_0 conda-forge sphinxcontrib-htmlhelp 2.0.0 pyhd8ed1ab_0 conda-forge sphinxcontrib-jsmath 1.0.1 py_0 conda-forge sphinxcontrib-qthelp 1.0.3 py_0 conda-forge sphinxcontrib-serializinghtml 1.1.5 pyhd8ed1ab_0 conda-forge sqlite 3.36.0 h9cd32fc_2 conda-forge sysroot_linux-64 2.12 he073ed8_14 conda-forge tensorboard 2.4.1 pyhd8ed1ab_1 conda-forge tensorboard-plugin-wit 1.8.0 pyh44b312d_0 conda-forge tensorflow 2.4.3 py38h578d9bd_0 conda-forge tensorflow-base 2.4.3 py38h83f5f1d_0 conda-forge tensorflow-estimator 2.4.0 pyh9656e83_0 conda-forge termcolor 1.1.0 py_2 conda-forge terminado 0.12.1 py38h578d9bd_0 conda-forge testpath 0.5.0 pyhd8ed1ab_0 conda-forge threadpoolctl 3.0.0 pyh8a188c0_0 conda-forge tifffile 2021.10.10 pyhd8ed1ab_0 conda-forge tk 8.6.11 h27826a3_1 conda-forge toml 0.10.2 pyhd8ed1ab_0 conda-forge tomli 1.2.1 pyhd8ed1ab_0 conda-forge toolz 0.11.1 py_0 conda-forge tornado 6.1 py38h497a2fe_1 conda-forge tqdm 4.62.3 pyhd8ed1ab_0 conda-forge traitlets 5.1.0 pyhd8ed1ab_0 conda-forge typing-extensions 3.7.4.3 0 conda-forge typing_extensions 3.7.4.3 py_0 conda-forge urllib3 1.26.7 pyhd8ed1ab_0 conda-forge wcwidth 0.2.5 pyh9f0ad1d_2 conda-forge webencodings 0.5.1 py_1 conda-forge werkzeug 2.0.1 pyhd8ed1ab_0 conda-forge wheel 0.37.0 pyhd8ed1ab_1 conda-forge widgetsnbextension 3.5.1 py38h578d9bd_4 conda-forge wrapt 1.13.1 py38h497a2fe_0 conda-forge x264 1!161.3030 h7f98852_1 conda-forge xorg-kbproto 1.0.7 h7f98852_1002 conda-forge xorg-libice 1.0.10 h7f98852_0 conda-forge xorg-libsm 1.2.3 hd9c2040_1000 conda-forge xorg-libx11 1.7.2 h7f98852_0 conda-forge xorg-libxau 1.0.9 h7f98852_0 conda-forge xorg-libxdmcp 1.1.3 h7f98852_0 conda-forge xorg-libxext 1.3.4 h7f98852_1 conda-forge xorg-libxrender 0.9.10 h7f98852_1003 conda-forge xorg-renderproto 0.11.1 h7f98852_1002 conda-forge xorg-xextproto 7.3.0 h7f98852_1002 conda-forge xorg-xproto 7.0.31 h7f98852_1007 conda-forge xz 5.2.5 h516909a_1 conda-forge yaml 0.2.5 h516909a_0 conda-forge yarl 1.7.0 py38h497a2fe_0 conda-forge zc-buildout 2.13.4 pypi_0 pypi zc-recipe-egg 2.0.7 pypi_0 pypi zeromq 4.3.4 h9c3ff4c_1 conda-forge zfp 0.5.5 h9c3ff4c_7 conda-forge zipp 3.6.0 pyhd8ed1ab_0 conda-forge zlib 1.2.11 h36c2ea0_1013 conda-forge zstd 1.5.0 ha95c52a_0 conda-forge ```


Details about conda and system ( conda info ):

``` $ conda info active environment : blitz active env location : /home/amir/miniconda/envs/blitz shell level : 1 user config file : /home/amir/.condarc populated config files : /home/amir/miniconda/.condarc /home/amir/.condarc /home/amir/miniconda/envs/blitz/condarc conda version : 4.10.3 conda-build version : 3.21.4 python version : 3.9.7.final.0 virtual packages : __linux=5.14.10=0 __glibc=2.33=0 __unix=0=0 __archspec=1=x86_64 base environment : /home/amir/miniconda (writable) conda av data dir : /home/amir/miniconda/etc/conda conda av metadata url : None channel URLs : http://www.idiap.ch/software/bob/conda/label/beta/linux-64 http://www.idiap.ch/software/bob/conda/label/beta/noarch http://www.idiap.ch/software/bob/conda/linux-64 http://www.idiap.ch/software/bob/conda/noarch https://conda.anaconda.org/conda-forge/linux-64 https://conda.anaconda.org/conda-forge/noarch package cache : /home/amir/miniconda/pkgs /home/amir/.conda/pkgs envs directories : /home/amir/miniconda/envs /home/amir/.conda/envs platform : linux-64 user-agent : conda/4.10.3 requests/2.26.0 CPython/3.9.7 Linux/5.14.10-200.fc34.x86_64 fedora/34 glibc/2.33 UID:GID : 1000:1000 netrc file : None offline mode : False ```
isuruf commented 2 years ago

Can you send the output when LD_DEBUG=libs is set for both scenarios?

183amir commented 2 years ago

Here are the steps to reproduce this issue:

$ conda create -n blitz \
-c https://www.idiap.ch/software/bob/conda/label/beta -c conda-forge \
python=3.8 bob.extension tensorflow=2.4 compilers pip click-plugins boost libblitz pkg-config --yes
# only bob.extension (a noarch package) will come from https://www.idiap.ch/software/bob/conda/label/beta
$ conda activate blitz
$ git clone https://github.com/bioidiap/bob.blitz.git
$ cd bob.blitz
$ python -m pip install -e .
$ python -c "import tensorflow, bob.blitz" # works
$ python -c "import bob.blitz, tensorflow" # breaks
free(): invalid pointer

And here is the output of:

183amir commented 2 years ago

And here are the compile and link commands of bob.blitz:

  Running setup.py develop for bob.blitz
    Running command /home/amir/miniconda/envs/blitz/bin/python3.8 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/amir/idiap/git/bob/bob.blitz/setup.py'"'"'; __file__='"'"'/home/amir/idiap/git/bob/bob.blitz/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
    running develop
    running egg_info
    creating bob.blitz.egg-info
    writing bob.blitz.egg-info/PKG-INFO
    writing dependency_links to bob.blitz.egg-info/dependency_links.txt
    writing requirements to bob.blitz.egg-info/requires.txt
    writing top-level names to bob.blitz.egg-info/top_level.txt
    writing manifest file 'bob.blitz.egg-info/SOURCES.txt'
    reading manifest file 'bob.blitz.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    adding license file 'LICENSE'
    writing manifest file 'bob.blitz.egg-info/SOURCES.txt'
    running build_ext
    building 'bob.blitz.version' extension
    creating build
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/bob
    creating build/temp.linux-x86_64-3.8/bob/blitz
    /home/amir/miniconda/envs/blitz/bin/x86_64-conda-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/amir/miniconda/envs/blitz/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/amir/miniconda/envs/blitz/include -fPIC -Wno-strict-aliasing -DBOB_EXT_MODULE_PREFIX="bob.blitz" -DBOB_EXT_MODULE_NAME="version" -DBOB_EXT_ENTRY_NAME=PyInit_version -DBOB_EXT_MODULE_VERSION="2.0.24b0" -DHAVE_BOOST=1 -DHAVE_BLITZ=1 -DPY_ARRAY_UNIQUE_SYMBOL=BOB_BLITZ_NUMPY_C_API -DNO_IMPORT_ARRAY=1 -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -I/home/amir/idiap/git/bob/bob.blitz/bob/blitz/include -I/tmp/pip-build-env-by8_4g2l/overlay/lib/python3.8/site-packages/bob/extension/include -I/home/amir/miniconda/envs/blitz/include/python3.8 -c bob/blitz/version.cpp -o build/temp.linux-x86_64-3.8/bob/blitz/version.o -fvisibility-inlines-hidden -std=c++17 -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -pthread -isystem /tmp/pip-build-env-by8_4g2l/overlay/lib/python3.8/site-packages/numpy/core/include -isystem /home/amir/miniconda/envs/blitz/include
    creating build/lib.linux-x86_64-3.8
    creating build/lib.linux-x86_64-3.8/bob
    creating build/lib.linux-x86_64-3.8/bob/blitz
    /home/amir/miniconda/envs/blitz/bin/x86_64-conda-linux-gnu-c++ -pthread -shared -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-rpath,/home/amir/miniconda/envs/blitz/lib -L/home/amir/miniconda/envs/blitz/lib -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-rpath,/home/amir/miniconda/envs/blitz/lib -L/home/amir/miniconda/envs/blitz/lib -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/home/amir/miniconda/envs/blitz/lib -Wl,-rpath-link,/home/amir/miniconda/envs/blitz/lib -L/home/amir/miniconda/envs/blitz/lib -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/amir/miniconda/envs/blitz/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/amir/miniconda/envs/blitz/include build/temp.linux-x86_64-3.8/bob/blitz/version.o -L/home/amir/miniconda/envs/blitz/lib -Wl,-R/home/amir/miniconda/envs/blitz/lib -lblitz -o build/lib.linux-x86_64-3.8/bob/blitz/version.cpython-38-x86_64-linux-gnu.so
    building 'bob.blitz._library' extension

########## Below might be important ############

    /home/amir/miniconda/envs/blitz/bin/x86_64-conda-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/amir/miniconda/envs/blitz/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/amir/miniconda/envs/blitz/include -fPIC -Wno-strict-aliasing -DBOB_EXT_MODULE_PREFIX="bob.blitz" -DBOB_EXT_MODULE_NAME="_library" -DBOB_EXT_ENTRY_NAME=PyInit__library -DBOB_EXT_MODULE_VERSION="2.0.24b0" -DHAVE_BOOST=1 -DHAVE_BLITZ=1 -DPY_ARRAY_UNIQUE_SYMBOL=BOB_BLITZ_NUMPY_C_API -DNO_IMPORT_ARRAY=1 -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -I/home/amir/idiap/git/bob/bob.blitz/bob/blitz/include -I/tmp/pip-build-env-by8_4g2l/overlay/lib/python3.8/site-packages/bob/extension/include -I/home/amir/miniconda/envs/blitz/include/python3.8 -c bob/blitz/api.cpp -o build/temp.linux-x86_64-3.8/bob/blitz/api.o -fvisibility-inlines-hidden -std=c++17 -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -pthread -isystem /tmp/pip-build-env-by8_4g2l/overlay/lib/python3.8/site-packages/numpy/core/include -isystem /home/amir/miniconda/envs/blitz/include
    /home/amir/miniconda/envs/blitz/bin/x86_64-conda-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/amir/miniconda/envs/blitz/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/amir/miniconda/envs/blitz/include -fPIC -Wno-strict-aliasing -DBOB_EXT_MODULE_PREFIX="bob.blitz" -DBOB_EXT_MODULE_NAME="_library" -DBOB_EXT_ENTRY_NAME=PyInit__library -DBOB_EXT_MODULE_VERSION="2.0.24b0" -DHAVE_BOOST=1 -DHAVE_BLITZ=1 -DPY_ARRAY_UNIQUE_SYMBOL=BOB_BLITZ_NUMPY_C_API -DNO_IMPORT_ARRAY=1 -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -I/home/amir/idiap/git/bob/bob.blitz/bob/blitz/include -I/tmp/pip-build-env-by8_4g2l/overlay/lib/python3.8/site-packages/bob/extension/include -I/home/amir/miniconda/envs/blitz/include/python3.8 -c bob/blitz/array.cpp -o build/temp.linux-x86_64-3.8/bob/blitz/array.o -fvisibility-inlines-hidden -std=c++17 -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -pthread -isystem /tmp/pip-build-env-by8_4g2l/overlay/lib/python3.8/site-packages/numpy/core/include -isystem /home/amir/miniconda/envs/blitz/include
    /home/amir/miniconda/envs/blitz/bin/x86_64-conda-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/amir/miniconda/envs/blitz/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/amir/miniconda/envs/blitz/include -fPIC -Wno-strict-aliasing -DBOB_EXT_MODULE_PREFIX="bob.blitz" -DBOB_EXT_MODULE_NAME="_library" -DBOB_EXT_ENTRY_NAME=PyInit__library -DBOB_EXT_MODULE_VERSION="2.0.24b0" -DHAVE_BOOST=1 -DHAVE_BLITZ=1 -DPY_ARRAY_UNIQUE_SYMBOL=BOB_BLITZ_NUMPY_C_API -DNO_IMPORT_ARRAY=1 -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -I/home/amir/idiap/git/bob/bob.blitz/bob/blitz/include -I/tmp/pip-build-env-by8_4g2l/overlay/lib/python3.8/site-packages/bob/extension/include -I/home/amir/miniconda/envs/blitz/include/python3.8 -c bob/blitz/main.cpp -o build/temp.linux-x86_64-3.8/bob/blitz/main.o -fvisibility-inlines-hidden -std=c++17 -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -pthread -isystem /tmp/pip-build-env-by8_4g2l/overlay/lib/python3.8/site-packages/numpy/core/include -isystem /home/amir/miniconda/envs/blitz/include
    /home/amir/miniconda/envs/blitz/bin/x86_64-conda-linux-gnu-c++ -pthread -shared -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-rpath,/home/amir/miniconda/envs/blitz/lib -L/home/amir/miniconda/envs/blitz/lib -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-rpath,/home/amir/miniconda/envs/blitz/lib -L/home/amir/miniconda/envs/blitz/lib -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/home/amir/miniconda/envs/blitz/lib -Wl,-rpath-link,/home/amir/miniconda/envs/blitz/lib -L/home/amir/miniconda/envs/blitz/lib -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/amir/miniconda/envs/blitz/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/amir/miniconda/envs/blitz/include build/temp.linux-x86_64-3.8/bob/blitz/api.o build/temp.linux-x86_64-3.8/bob/blitz/array.o build/temp.linux-x86_64-3.8/bob/blitz/main.o -L/home/amir/miniconda/envs/blitz/lib -Wl,-R/home/amir/miniconda/envs/blitz/lib -lblitz -o build/lib.linux-x86_64-3.8/bob/blitz/_library.cpython-38-x86_64-linux-gnu.so

########## Above might be important ############

    copying build/lib.linux-x86_64-3.8/bob/blitz/version.cpython-38-x86_64-linux-gnu.so -> bob/blitz
    copying build/lib.linux-x86_64-3.8/bob/blitz/_library.cpython-38-x86_64-linux-gnu.so -> bob/blitz
    Creating /home/amir/miniconda/envs/blitz/lib/python3.8/site-packages/bob.blitz.egg-link (link to .)
    Adding bob.blitz 2.0.24b0 to easy-install.pth file

    Installed /home/amir/idiap/git/bob/bob.blitz
Successfully installed bob.blitz-2.0.24b0
183amir commented 2 years ago

I have also narrowed down where in tensorflow the code breaks which is here: https://github.com/tensorflow/tensorflow/blob/v2.4.3/tensorflow/lite/experimental/microfrontend/python/ops/audio_microfrontend_op.py#L29 where the code breaks in a setting like:

def load_op_library(library_filename):
    # loading with dlopen RTLD_LOCAL | RTLD_NOW
    lib_handle = py_tf.TF_LoadLibrary(library_filename)
    try:
        tmp = py_tf.TF_GetOpList(lib_handle)
        wrappers = _pywrap_python_op_gen.GetPythonWrappers(tmp) # breaks here
    finally:
        py_tf.TF_DeleteLibraryHandle(lib_handle)

_audio_microfrontend_op = load_op_library("_audio_microfrontend_op.so")
isuruf commented 2 years ago

It seems like libblitz is linked with -ffast-math. When a library is linked with -ffast-math (not compiled with -ffast-math) it links in a special runtime that would set some FPU registers at load time. When libstdc++.so is loaded after the FPU registers are changed, it must be changing some behaviour of libstdc++ that tensorflow is relying on. Still, libstdc++.so should work, but I guess there's an upstream bug in gcc. There's nothing we can do here though except removing -ffast-math.

At conda-forge, we strongly discourage linking with -ffast-math due to it changing the behaviour of all libraries loaded into the process. Compiling with -ffast-math is still okay if it is isolated and doesn't use header only libraries.

183amir commented 2 years ago

Thanks a lot for looking into this, you're right that this has to do with libstdc++ some library loading first or not. For example, both of the commands below work:

$ LD_PRELOAD=/home/amir/miniconda/envs/blitz/lib/libstdc++.so.6 python -c "import bob.blitz, tensorflow"
# or
$ LD_PRELOAD=/lib64/libstdc++.so.6 python -c "import bob.blitz, tensorflow"

I tried recompiling libblitz using the changes in https://github.com/conda-forge/libblitz-feedstock/pull/17 and testing again, but, I still get the same error. Looking at the logs of libblitz building, I can see that -ffast-math is removed, so I am not sure if that is the problem or the only problem.

Also, I noticed that even doing:

$ LD_PRELOAD=/home/amir/miniconda/envs/blitz/lib/libblitz.so.0 python -c "import bob.blitz, tensorflow"
# or
$ LD_PRELOAD=/home/amir/idiap/git/bob/bob.blitz/bob/blitz/_library.cpython-38-x86_64-linux-gnu.so python -c "import bob.blitz, tensorflow"

would fix the crash, where:

$ ldd -d /home/amir/miniconda/envs/blitz/lib/libblitz.so.0
    linux-vdso.so.1 (0x00007fff6b1f3000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f91f36fd000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f91f352e000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f91f396e000)
    libgcc_s.so.1 => /home/amir/miniconda/envs/blitz/lib/./libgcc_s.so.1 (0x00007f91f3519000)
183amir commented 2 years ago

was fixed in https://github.com/conda-forge/ctng-compilers-feedstock/pull/76 and https://github.com/conda-forge/libblitz-feedstock/pull/17