jupyter-xeus / xeus-cling

Jupyter kernel for the C++ programming language
BSD 3-Clause "New" or "Revised" License
3.01k stars 294 forks source link

Segfault when Launching --help from conda-forge Installation / Installaiton Instruction could be Expanded #496

Open stellarpower opened 9 months ago

stellarpower commented 9 months ago

Hi,

It's nice that the installation instructions are pretty ting, and that the process is simple. But, I feel these could be epxanded for when things go wrong...:

I'm trying to launch a notebook from within VS Code. I'll take the web interface if that's all that will work right now, but, as it's nice to step through in a debugger, and I have used VS Code for PYthon notebooks before, I started there. The kernel doesn't seem to launch fully, so I then broke open a shell to look at what is going on.

It may not be critical, but I get a segfault when I just try to run xcpp --help, so that feels something to be sorted first.

[🍑] user@host ~> micromamba --version                                   
1.5.0
[🍑] user@host ~> micromamba env create -c conda-forge -n Xeus-ClingBugReport
Empty environment created at prefix: /MicromambaRoot/envs/Xeus-ClingBugReport
[🍑] user@host ~> micromamba activate  Xeus-ClingBugReport
[🍑] user@host ~> micromamba install -c conda-forge  xeus-cling                                                                                                          (Xeus-ClingBugReport) 
conda-forge/linux-64                                        Using cache
conda-forge/noarch                                          Using cache

Transaction

  Prefix: /MicromambaRoot/envs/Xeus-ClingBugReport

  Updating specs:

   - xeus-cling

  Package                       Version  Build                  Channel           Size
────────────────────────────────────────────────────────────────────────────────────────
  Install:
────────────────────────────────────────────────────────────────────────────────────────

  + nlohmann_json                3.11.2  h27087fc_0             conda-forge     Cached
  + _libgcc_mutex                   0.1  conda_forge            conda-forge     Cached
  + libstdcxx-ng                 13.2.0  h7e041cc_1             conda-forge     Cached
  + ca-certificates           2023.7.22  hbcca054_0             conda-forge     Cached
  + libstdcxx-devel_linux-64     10.4.0  hd38fd1e_19            conda-forge     Cached
  + libgcc-devel_linux-64        10.4.0  hd38fd1e_19            conda-forge     Cached
  + ld_impl_linux-64               2.39  hcc3a1bd_1             conda-forge     Cached
  + libgomp                      13.2.0  h807b86a_1             conda-forge     Cached
  + _openmp_mutex                   4.5  2_gnu                  conda-forge     Cached
  + libgcc-ng                    13.2.0  h807b86a_1             conda-forge     Cached
  + libsodium                    1.0.18  h36c2ea0_1             conda-forge     Cached
  + libsanitizer                 10.4.0  h5246dfb_19            conda-forge     Cached
  + libzlib                      1.2.13  hd590300_5             conda-forge     Cached
  + openssl                       3.1.2  hd590300_0             conda-forge     Cached
  + libuuid                      2.38.1  h0b41bf4_0             conda-forge     Cached
  + xtl                           0.7.5  hf52228f_0             conda-forge     Cached
  + pugixml                        1.13  h59595ed_1             conda-forge     Cached
  + zeromq                        4.3.4  h9c3ff4c_1             conda-forge     Cached
  + libllvm9                      9.0.1  default_hc23dcda_7     conda-forge     Cached
  + xeus                          3.1.1  h06414e2_0             conda-forge     Cached
  + cppzmq                        4.9.0  he78764c_0             conda-forge     Cached
  + llvm-tools                    9.0.1  cling_v0.9_h2b820e9_7  conda-forge     Cached
  + libclang-cpp9                 9.0.1  cling_v0.9_h6699504_5  conda-forge     Cached
  + libclang                      9.0.1  cling_v0.9_h1e27157_5  conda-forge     Cached
  + xeus-zmq                      1.1.0  h243c08f_0             conda-forge     Cached
  + llvmdev                       9.0.1  cling_v0.9_h2b820e9_7  conda-forge     Cached
  + clang-9                       9.0.1  cling_v0.9_h6699504_5  conda-forge     Cached
  + libclang-cpp                  9.0.1  cling_v0.9_h6699504_5  conda-forge     Cached
  + kernel-headers_linux-64      2.6.32  he073ed8_16            conda-forge     Cached
  + sysroot_linux-64               2.12  he073ed8_16            conda-forge     Cached
  + binutils_impl_linux-64         2.39  he00db2b_1             conda-forge     Cached
  + gcc_impl_linux-64            10.4.0  h5231bdf_19            conda-forge     Cached
  + binutils_linux-64              2.39  h5fc0e48_13            conda-forge     Cached
  + gxx_impl_linux-64            10.4.0  h5231bdf_19            conda-forge     Cached
  + clang                         9.0.1  cling_v0.9_hf01e6bc_5  conda-forge     Cached
  + gcc_linux-64                 10.4.0  h9215b83_13            conda-forge     Cached
  + clangxx                       9.0.1  cling_v0.9_he14baed_5  conda-forge     Cached
  + gxx_linux-64                 10.4.0  h6e491c6_13            conda-forge     Cached
  + clang-tools                   9.0.1  cling_v0.9_h1e27157_5  conda-forge     Cached
  + clangdev                      9.0.1  cling_v0.9_h1e27157_5  conda-forge     Cached
  + cling                           0.9  he0ac6c6_1             conda-forge     Cached
  + xeus-cling                   0.15.3  h7bb6b15_1             conda-forge     Cached

  Summary:

  Install: 42 packages

  Total download: 0 B

────────────────────────────────────────────────────────────────────────────────────────

Confirm changes: [Y/n] y

Transaction starting
Linking nlohmann_json-3.11.2-h27087fc_0
Linking _libgcc_mutex-0.1-conda_forge
Linking libstdcxx-ng-13.2.0-h7e041cc_1
Linking ca-certificates-2023.7.22-hbcca054_0
Linking libstdcxx-devel_linux-64-10.4.0-hd38fd1e_19
Linking libgcc-devel_linux-64-10.4.0-hd38fd1e_19
Linking ld_impl_linux-64-2.39-hcc3a1bd_1
Linking libgomp-13.2.0-h807b86a_1
Linking _openmp_mutex-4.5-2_gnu
Linking libgcc-ng-13.2.0-h807b86a_1
Linking libsodium-1.0.18-h36c2ea0_1
Linking libsanitizer-10.4.0-h5246dfb_19
Linking libzlib-1.2.13-hd590300_5
Linking openssl-3.1.2-hd590300_0
Linking libuuid-2.38.1-h0b41bf4_0
Linking xtl-0.7.5-hf52228f_0
Linking pugixml-1.13-h59595ed_1
Linking zeromq-4.3.4-h9c3ff4c_1
Linking libllvm9-9.0.1-default_hc23dcda_7
Linking xeus-3.1.1-h06414e2_0
Linking cppzmq-4.9.0-he78764c_0
Linking llvm-tools-9.0.1-cling_v0.9_h2b820e9_7
Linking libclang-cpp9-9.0.1-cling_v0.9_h6699504_5
Linking libclang-9.0.1-cling_v0.9_h1e27157_5
Linking xeus-zmq-1.1.0-h243c08f_0
Linking llvmdev-9.0.1-cling_v0.9_h2b820e9_7
Linking clang-9-9.0.1-cling_v0.9_h6699504_5
Linking libclang-cpp-9.0.1-cling_v0.9_h6699504_5
Linking kernel-headers_linux-64-2.6.32-he073ed8_16
Linking sysroot_linux-64-2.12-he073ed8_16
Linking binutils_impl_linux-64-2.39-he00db2b_1
Linking gcc_impl_linux-64-10.4.0-h5231bdf_19
Linking binutils_linux-64-2.39-h5fc0e48_13
Linking gxx_impl_linux-64-10.4.0-h5231bdf_19
Linking clang-9.0.1-cling_v0.9_hf01e6bc_5
Linking gcc_linux-64-10.4.0-h9215b83_13
Linking clangxx-9.0.1-cling_v0.9_he14baed_5
Linking gxx_linux-64-10.4.0-h6e491c6_13
Linking clang-tools-9.0.1-cling_v0.9_h1e27157_5
warning  libmamba [clang-tools-9.0.1-cling_v0.9_h1e27157_5] The following files were already present in the environment:
    - lib/libclang-cpp.so
Linking clangdev-9.0.1-cling_v0.9_h1e27157_5
Linking cling-0.9-he0ac6c6_1
Linking xeus-cling-0.15.3-h7bb6b15_1

Transaction finished

To activate this environment, use:

    micromamba activate Xeus-ClingBugReport

Or to execute a single command in this environment, use:

    micromamba run -n Xeus-ClingBugReport mycommand

[🍑] user@host ~> xcpp --help &| c++filt                                                                                                                                 (Xeus-ClingBugReport) 
alias
registering handler for SIGSEGV
OVERVIEW: cling: LLVM/clang C++ Interpreter: http://cern.ch/cling

USAGE: cling

OPTIONS:
  --errorout        Do not recover from input errors
  -help             Print this help text
  -L <directory>    Add directory to library search path
  -long <library>      Load signed char library before prompt
  --metastr=<value> Set the meta command tag, default '.'
  --metastr <value> Set the meta command tag, default '.'
  --nologo          Do not show startup-banner
  -noruntime        Disable runtime support (no null checking, no value printing)
  -version          Print the compiler version
  -void                Enable verbose output

OVERVIEW: LLVM 'Clang' Compiler: http://clang.llvm.org

USAGE: clang -cc1

CL.EXE COMPATIBILITY OPTIONS:
  /?                      Display available options
  /arch:<value>           Set architecture for code generation
  /Brepro-                Write current time into COFF output (default)

  ...
  ...
  ...

  -Xopenmp-target=<triple> <arg>
                          Pass <arg> to the target offloading toolchain identified by <triple>.
  -Xopenmp-target <arg>   Pass <arg> to the target offloading toolchain.
  -Xpreprocessor <arg>    Pass <arg> to the preprocessor
  -long long <language>           Treat subsequent input files as having type <language>
  -... <arg>                Pass -... <arg> to the linker

Error: signal 11:
xcpp(handler(int)+0x2b)[0x55af6620906b]
/lib/x86_64-linux-gnu/libc.so.6(+0x3c4b0)[0x7fac4d43c4b0]
/MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/libxeus-cling.so.0(cling::Interpreter::getCI() const+0x7)[0x7fac52dfddd7]
/MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/libxeus-cling.so.0(cling::Interpreter::AddIncludePaths(llvm::StringRef, char const*)+0x46)[0x7fac52e05e46]
/MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/libxeus-cling.so.0(xcpp::interpreter::init_extra_includes()+0x271)[0x7fac52d8f591]
/MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/libxeus-cling.so.0(xcpp::interpreter::interpreter(int, char const* const*)+0x6ee)[0x7fac52dbbdee]
xcpp(build_interpreter(int, char**)+0x29b)[0x55af66209dbb]
xcpp(main+0xdf)[0x55af6620850f]
/lib/x86_64-linux-gnu/libc.so.6(+0x23a90)[0x7fac4d423a90]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x89)[0x7fac4d423b49]

[🍑] user@host ~> ldd (command -v xcpp)                                                                                                                                  (Xeus-ClingBugReport) 
        linux-vdso.so.1 (0x00007ffcd8ccd000)
        libxeus-cling.so.0 => /MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/libxeus-cling.so.0 (0x00007f6e13c00000)
        libLLVM-9.so => /MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/libLLVM-9.so (0x00007f6e0ec00000)
        libxeus-zmq.so.2 => /MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/libxeus-zmq.so.2 (0x00007f6e13b8c000)
        libzmq.so.5 => /MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/libzmq.so.5 (0x00007f6e13aef000)
        libxeus.so.9 => /MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/libxeus.so.9 (0x00007f6e13a6d000)
        libstdc++.so.6 => /MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/libstdc++.so.6 (0x00007f6e0ea1d000)
        libgcc_s.so.1 => /MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/libgcc_s.so.1 (0x00007f6e13a52000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6e0e800000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f6e15a51000)
        libpugixml.so.1 => /MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/./libpugixml.so.1 (0x00007f6e0e7c3000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6e0e6da000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f6e15a67000)
        libz.so.1 => /MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/./libz.so.1 (0x00007f6e13a11000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6e15a4a000)
        libcrypto.so.3 => /MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/./libcrypto.so.3 (0x00007f6e0e000000)
        libsodium.so.23 => /MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/./libsodium.so.23 (0x00007f6e0e67f000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f6e13a0c000)
        libuuid.so.1 => /MicromambaRoot/envs/Xeus-ClingBugReport/bin/../lib/./libuuid.so.1 (0x00007f6e0ea14000)
[🍑] user@host ~>

The C library still seems to be coming form my system - If I include the logs form VS Code, you can see a warning about possible version mismatch:

19:16:25.956 [info] Dispose Kernel '/tmp/Xeus Demo Notebook.ipynb' associated with '/tmp/Xeus Demo Notebook.ipynb'
19:16:25.956 [info] Dispose Kernel process 1976825.
19:17:28.608 [info] Start refreshing Kernel Picker (1695151048608)
19:17:28.732 [error] Failed to get activated conda env vars for /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python3.11
                 in 110ms
19:17:28.732 [error] Unable to determine site packages path for python /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python3.11 (Conda)
19:17:28.752 [info] Process Execution: /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python3.11 -m pip list
19:17:29.626 [info] End refreshing Kernel Picker (1695151048608)
19:17:37.822 [info] Process Execution: /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python3.11 -c "import jupyter;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
19:17:37.842 [info] Process Execution: /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python3.11 -c "import notebook;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
19:17:37.874 [info] Process Execution: /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python3.11 -m jupyter kernelspec --version
19:17:38.030 [warn] No interpreter with path /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python found in Python API, will convert Uri path to string as Id /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python
19:17:38.081 [info] Start refreshing Kernel Picker (1695151058081)
19:17:38.118 [error] Failed to get activated conda env vars for /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python
                 in 32ms
19:17:38.118 [error] Unable to determine site packages path for python /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python (Conda)
19:17:38.132 [info] Process Execution: /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python -c "import jupyter;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
19:17:38.151 [info] Process Execution: /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python -c "import notebook;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
19:17:38.180 [info] Process Execution: /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python -m jupyter kernelspec --version
19:17:39.089 [info] End refreshing Kernel Picker (1695151058081)
19:17:46.728 [info] Process Execution: /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python -m pip list
19:17:46.741 [info] Starting Kernel startUsingLocalKernelSpec, .jvsc74a57bd01d18f535d0bd82abaafaf8716b7e7ed95b2db33560c5e28c2b34d69938f72741#xcpp17./media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python3.11././media/<username>/sdb_ext4/users/<username>/micromambaroot/envs/xeus-clingbugreport/bin//xcpp#-f#{connection_file}#-std=c++17  (Python Path: /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python3.11, Conda, 3.11.5) for '/tmp/Xeus Demo Notebook.ipynb' (disableUI=true)
19:17:46.754 [info] Launching Raw Kernel C++17 # /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin//xcpp
19:17:46.788 [error] Failed to get activated conda env vars for /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python3.11
                 in 33ms
19:17:46.788 [error] Unable to determine site packages path for python /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin/python3.11 (Conda)
19:17:46.819 [info] Process Execution: /media/<username>/SDB_EXT4/Users/<username>/MicromambaRoot/envs/Xeus-ClingBugReport/bin//xcpp -f ~/.local/share/jupyter/runtime/kernel-v2-1962684VSFBFJ9Gpqah.json -std=c++17
    > cwd: /tmp
19:17:47.368 [warn] StdErr from Kernel Process registering handler for SIGSEGV
19:17:50.098 [warn] StdErr from Kernel Process Starting xeus-cling kernel...

If you want to connect to this kernel from an other client, you can use the ~/.local/share/jupyter/runtime/kernel-v2-1962684VSFBFJ9Gpqah.json file.
19:17:50.098 [warn] StdErr from Kernel Process Run with XEUS 3.1.1

These <username>s are in the VS Code logs; I haven't redacted the path (as I have in the others), so need to work out what is going on there.

To do this for a clean MRE, I had to install python and the notebook package inside this environment - it seems VS Code wasn't happy finding the Xeus kernel without having a python interpreter in the mamba environment PATH I could point it to first.

then, I needed to re-install xeus-cling:


[🍑] user@host ~> micromamba install -c conda-forge  xeus-cling                                                                                                                             (Xeus-ClingBugReport) 
conda-forge/linux-64                                        Using cache
conda-forge/noarch                                          Using cache

Pinned packages:
  - python 3.11.*

Transaction

  Prefix: /MicromambaRoot/envs/Xeus-ClingBugReport

  Updating specs:

   - xeus-cling

  Package       Version  Build                  Channel           Size
────────────────────────────────────────────────────────────────────────
  Install:
────────────────────────────────────────────────────────────────────────

  + clangdev      9.0.1  cling_v0.9_h1e27157_5  conda-forge     Cached
  + cling           0.9  he0ac6c6_1             conda-forge     Cached
  + xeus-cling   0.15.3  h7bb6b15_1             conda-forge     Cached

  Remove:
────────────────────────────────────────────────────────────────────────

  - jupyter       1.0.0  py311h38be061_8        conda-forge     Cached
  - qtconsole     5.4.4  pyhd8ed1ab_0           conda-forge     Cached
  - pyqt         5.15.9  py311hf0fb5b6_4        conda-forge     Cached
  - qt-main      5.15.8  h01ceb2d_12            conda-forge     Cached

  Downgrade:
────────────────────────────────────────────────────────────────────────

  - libclang     16.0.6  default_h1cdf331_1     conda-forge     Cached
  + libclang      9.0.1  cling_v0.9_h1e27157_5  conda-forge     Cached

  Summary:

  Install: 3 packages
  Remove: 4 packages
  Downgrade: 1 packages

  Total download: 0 B

────────────────────────────────────────────────────────────────────────

Confirm changes: [Y/n] y

Transaction starting
Unlinking jupyter-1.0.0-py311h38be061_8
Unlinking qtconsole-5.4.4-pyhd8ed1ab_0
Unlinking pyqt-5.15.9-py311hf0fb5b6_4
Unlinking qt-main-5.15.8-h01ceb2d_12
Changing libclang-16.0.6-default_h1cdf331_1 ==> libclang-9.0.1-cling_v0.9_h1e27157_5
Linking clangdev-9.0.1-cling_v0.9_h1e27157_5
Linking cling-0.9-he0ac6c6_1
Linking xeus-cling-0.15.3-h7bb6b15_1

Transaction finished

To activate this environment, use:

    micromamba activate Xeus-ClingBugReport

Or to execute a single command in this environment, use:

    micromamba run -n Xeus-ClingBugReport mycommand

[🍑] user@host ~>       

Any advice? Is the backtrace a bug, or have I missed installing somehting essential, is micrommaba officially supported?

Thanks a lot!!