Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot install Cling kernel into a virtualenv Jupyter application #1

Closed
ulf1 opened this issue Feb 2, 2016 · 21 comments
Closed

Cannot install Cling kernel into a virtualenv Jupyter application #1

ulf1 opened this issue Feb 2, 2016 · 21 comments

Comments

@ulf1
Copy link

ulf1 commented Feb 2, 2016

Hello, i hope someone can help.

I installed Cling using simply this script

https://raw.github.com/karies/cling-all-in-one/master/clone.sh

I also added Cling to my PATH variable (in .bashrc), and can run stuff like this

cling '#include <stdio.h>' 'printf("Hello World!\n")'

Next I open my activate my virtualenv with Python 3.5.0 where Jupyter is installed (There is no Jupyter in my operating systems python3). There is no problem with Jupyter/Python3 within a virtualenv bcoz I am using it everyday. There is also not a problem with PATH and cling within the virtualenv (I can call call "cling" within the virtualenv).

If i am trying to install cling in jupyter
source /locationofmyvirtualenv/bin/activate
jupyter kernelspec install cling

I get the following error message

...
(venv-3.5.0)username@hostname:~$ jupyter kernelspec install cling
Traceback (most recent call last):
  File "/locationofmyvirtualenv/bin/jupyter-kernelspec", line 11, in 
    sys.exit(KernelSpecApp.launch_instance())
  File "/locationofmyvirtualenv/lib/python3.5/site-packages/traitlets/config/application.py", line 589, in launch_instance
    app.start()
  File "/locationofmyvirtualenv/lib/python3.5/site-packages/jupyter_client/kernelspecapp.py", line 209, in start
    return self.subapp.start()
  File "/locationofmyvirtualenv/lib/python3.5/site-packages/jupyter_client/kernelspecapp.py", line 138, in start
    replace=self.replace,
  File "/locationofmyvirtualenv/lib/python3.5/site-packages/jupyter_client/kernelspec.py", line 208, in install_kernel_spec
    shutil.copytree(source_dir, destination)
  File "/locationofmyvirtualenv/lib/python3.5/shutil.py", line 303, in copytree
    names = os.listdir(src)
FileNotFoundError: [Errno 2] No such file or directory: 'cling'
... 
@Axel-Naumann
Copy link
Member

I think "cling" needs to be in ./ for this...

@mjanv
Copy link

mjanv commented Feb 2, 2016

I've run into the same issue as @ulf1 on this installation : Ubuntu 14.04 in a VM, Python3.5 via Anaconda (jupyter v4.0.6 and jupyter notebook v4.1.0), no virtualenv, cling installed (at /usr/local/bin/cling) and tested.

By adding a symlink ./cling -> /usr/local/bin/cling, I overpass the previous error (similar to @ulf1's one) to get a new one :

vagrant@VMSandbox:~$ jupyter kernelspec install cling
Traceback (most recent call last):
  File "/home/vagrant/anaconda3/bin/jupyter-kernelspec", line 8, in <module>
    main()
  File "/home/vagrant/anaconda3/bin/jupyter-kernelspec", line 5, in main
    KernelSpecApp.launch_instance()
  File "/home/vagrant/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 592, in launch_instance
    app.start()
  File "/home/vagrant/anaconda3/lib/python3.5/site-packages/jupyter_client/kernelspecapp.py", line 209, in start
    return self.subapp.start()
  File "/home/vagrant/anaconda3/lib/python3.5/site-packages/jupyter_client/kernelspecapp.py", line 138, in start
    replace=self.replace,
  File "/home/vagrant/anaconda3/lib/python3.5/site-packages/jupyter_client/kernelspec.py", line 208, in install_kernel_spec
    shutil.copytree(source_dir, destination)
  File "/home/vagrant/anaconda3/lib/python3.5/shutil.py", line 303, in copytree
    names = os.listdir(src)
NotADirectoryError: [Errno 20] Not a directory: 'cling'

Any ideas ?

@Axel-Naumann
Copy link
Member

Yup, indeed - the doc was not clear. I /believe/ that this is the correct procedure:

To install the kernel with sources in src/tools/cling:

     cd src/tools/cling/tools/Jupyter/kernel/
     pip install -e .
     # register the kernelspec:
     jupyter kernelspec install [--user] cling

Could you confirm?

@mjanv
Copy link

mjanv commented Feb 3, 2016

Using your commands :

vagrant@VMSandbox:~/src/tools/cling/tools/Jupyter/kernel$ pip install -e .
Obtaining file:///home/vagrant/src/tools/cling/tools/Jupyter/kernel
Requirement already up-to-date: ipykernel in /home/vagrant/anaconda3/lib/python3.5/site-packages (from clingkernel==0.0.1)
Requirement already up-to-date: traitlets in /home/vagrant/anaconda3/lib/python3.5/site-packages (from clingkernel==0.0.1)
Installing collected packages: clingkernel
  Running setup.py develop for clingkernel
Successfully installed clingkernel-0.0.1
vagrant@VMSandbox:~/src/tools/cling/tools/Jupyter/kernel$ jupyter kernelspec install --user cling
[InstallKernelSpec] Installed kernelspec cling in /home/vagrant/.local/share/jupyter/kernels/cling

which somehow succeed to install the kernel. It appears in the list of available notebooks in Jupyter (yeah !) listed as C++, but the kernel keeps crashing because of this error (a dylib missing):

[I 09:15:52.046 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 1f5e9824-096e-453d-b987-0baad4d819af restarted
Traceback (most recent call last):
  File "/home/vagrant/anaconda3/bin/jupyter-cling-kernel", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/home/vagrant/src/tools/cling/tools/Jupyter/kernel/scripts/jupyter-cling-kernel", line 4, in <module>
    main()
  File "/home/vagrant/src/tools/cling/tools/Jupyter/kernel/clingkernel.py", line 278, in main
    ClingKernelApp.launch_instance()
  File "/home/vagrant/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 588, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-121>", line 2, in initialize
  File "/home/vagrant/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/vagrant/anaconda3/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 384, in initialize
    self.init_kernel()
  File "/home/vagrant/anaconda3/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 323, in init_kernel
    user_ns=self.user_ns,
  File "/home/vagrant/anaconda3/lib/python3.5/site-packages/traitlets/config/configurable.py", line 404, in instance
    inst = cls(*args, **kwargs)
  File "/home/vagrant/src/tools/cling/tools/Jupyter/kernel/clingkernel.py", line 77, in __init__
    self.libclingJupyter = ctypes.CDLL(clingInstDir + "/lib/libclingJupyter.dylib", mode = ctypes.RTLD_GLOBAL)
  File "/home/vagrant/anaconda3/lib/python3.5/ctypes/__init__.py", line 347, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/local/lib/libclingJupyter.dylib: cannot open shared object file: No such file or directory

We're running in a new problem which was not the primer purpose of the issue. I'd like to know if @ulf1 succeed to overcome the error as well.

@Axel-Naumann
Copy link
Member

Please start jupyter with cling in the $PATH. I.e. is /usr/local/bin in your $PATH? I will try to improve the error message if that's the case :-)

If it is - do you have something here: /usr/local/lib/libclingJupyter.* In my case, that library does get installed...

@mjanv
Copy link

mjanv commented Feb 3, 2016

Yes, i have already checked that cling was in the PATH (/home/vagrant/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games) through /usr/local/bin

I did not find any libclingJupyter on my system. Any steps, options, I missed ?

vagrant@VMSandbox:/code$ ls /usr/local/lib/
BugpointPasses.so                 libLLVMMCDisassembler.a
clang                             libLLVMMCJIT.a
libclang.a                        libLLVMMCParser.a
libclangAnalysis.a                libLLVMMipsAsmParser.a
libclangARCMigrate.a              libLLVMMipsAsmPrinter.a
libclangAST.a                     libLLVMMipsCodeGen.a
libclangASTMatchers.a             libLLVMMipsDesc.a
libclangBasic.a                   libLLVMMipsDisassembler.a
libclangCodeGen.a                 libLLVMMipsInfo.a
libclangDriver.a                  libLLVMMSP430AsmPrinter.a
libclangDynamicASTMatchers.a      libLLVMMSP430CodeGen.a
libclangEdit.a                    libLLVMMSP430Desc.a
libclangFormat.a                  libLLVMMSP430Info.a
libclangFrontend.a                libLLVMNVPTXAsmPrinter.a
libclangFrontendTool.a            libLLVMNVPTXCodeGen.a
libclangIndex.a                   libLLVMNVPTXDesc.a
libclangLex.a                     libLLVMNVPTXInfo.a
libclangParse.a                   libLLVMObjCARCOpts.a
libclangRewrite.a                 libLLVMObject.a
libclangRewriteFrontend.a         libLLVMOption.a
libclangSema.a                    libLLVMOrcJIT.a
libclangSerialization.a           libLLVMPowerPCAsmParser.a
libclang.so                       libLLVMPowerPCAsmPrinter.a
libclangStaticAnalyzerCheckers.a  libLLVMPowerPCCodeGen.a
libclangStaticAnalyzerCore.a      libLLVMPowerPCDesc.a
libclangStaticAnalyzerFrontend.a  libLLVMPowerPCDisassembler.a
libclangTooling.a                 libLLVMPowerPCInfo.a
libclangToolingCore.a             libLLVMProfileData.a
libclingInterpreter.a             libLLVMR600AsmParser.a
libclingMetaProcessor.a           libLLVMR600AsmPrinter.a
libclingUITextInput.a             libLLVMR600CodeGen.a
libclingUserInterface.a           libLLVMR600Desc.a
libclingUtils.a                   libLLVMR600Info.a
libLLVMAArch64AsmParser.a         libLLVMRuntimeDyld.a
libLLVMAArch64AsmPrinter.a        libLLVMScalarOpts.a
libLLVMAArch64CodeGen.a           libLLVMSelectionDAG.a
libLLVMAArch64Desc.a              libLLVMSparcAsmParser.a
libLLVMAArch64Disassembler.a      libLLVMSparcAsmPrinter.a
libLLVMAArch64Info.a              libLLVMSparcCodeGen.a
libLLVMAArch64Utils.a             libLLVMSparcDesc.a
libLLVMAnalysis.a                 libLLVMSparcDisassembler.a
libLLVMARMAsmParser.a             libLLVMSparcInfo.a
libLLVMARMAsmPrinter.a            libLLVMSupport.a
libLLVMARMCodeGen.a               libLLVMSystemZAsmParser.a
libLLVMARMDesc.a                  libLLVMSystemZAsmPrinter.a
libLLVMARMDisassembler.a          libLLVMSystemZCodeGen.a
libLLVMARMInfo.a                  libLLVMSystemZDesc.a
libLLVMAsmParser.a                libLLVMSystemZDisassembler.a
libLLVMAsmPrinter.a               libLLVMSystemZInfo.a
libLLVMBitReader.a                libLLVMTableGen.a
libLLVMBitWriter.a                libLLVMTarget.a
libLLVMCodeGen.a                  libLLVMTransformUtils.a
libLLVMCore.a                     libLLVMVectorize.a
libLLVMCppBackendCodeGen.a        libLLVMX86AsmParser.a
libLLVMCppBackendInfo.a           libLLVMX86AsmPrinter.a
libLLVMDebugInfoDWARF.a           libLLVMX86CodeGen.a
libLLVMExecutionEngine.a          libLLVMX86Desc.a
libLLVMHexagonCodeGen.a           libLLVMX86Disassembler.a
libLLVMHexagonDesc.a              libLLVMX86Info.a
libLLVMHexagonDisassembler.a      libLLVMX86Utils.a
libLLVMHexagonInfo.a              libLLVMXCoreAsmPrinter.a
libLLVMInstCombine.a              libLLVMXCoreCodeGen.a
libLLVMInstrumentation.a          libLLVMXCoreDesc.a
libLLVMInterpreter.a              libLLVMXCoreDisassembler.a
libLLVMipa.a                      libLLVMXCoreInfo.a
libLLVMipo.a                      libLTO.a
libLLVMIRReader.a                 libLTO.so
libLLVMLineEditor.a               LLVMHello.so
libLLVMLinker.a                   python2.7
libLLVMLTO.a                      python3.4
libLLVMMC.a                       site_ruby

@Axel-Naumann
Copy link
Member

Understood - libclingJupyter is only built using CMake. Given that llvm has removed autoconf I have switched clone.sh to CMake, too.

Please rm -rf obj and re-run ./clone.sh after pulling it. Let me know if you still see issues.

@lenck
Copy link

lenck commented Feb 7, 2016

I think this is a bug in the source code. Does this means that the cling kernel is supported only for Mac OSX when it has hard-coded *.dylib library loading?

@Axel-Naumann
Copy link
Member

Ouch. That should be fixed in the current HEAD. Could you give it a spin?

Thanks for reporting!

@ObiWahn
Copy link
Contributor

ObiWahn commented Feb 15, 2016

Hi,

I am trying to install cling to a docker container and i run in smilar problems. I have configured cling with --prefix=/usr/local. i am ab bit confused about: To install the kernel with sources in src/tools/cling: is that a prefix do you really mean to install to the source tree? Please update the README!!

Here is a part of my docker log:

Step 17 : RUN ls -lisa /usr/local/bin
 ---> Running in 89abc70b876b
total 3957804
 10916322      4 drwxrwsr-x  2 root staff      4096 Feb 15 07:40 .
 10841467      4 drwxrwsr-x 11 root staff      4096 Feb 15 07:40 ..
128320570   3680 -rwxr-xr-x  2 root staff   3766800 Feb 15 07:34 FileCheck
128320571 158856 -rwxr-xr-x  2 root staff 162667632 Feb 15 07:34 bugpoint
128320572    172 -rwxr-xr-x  2 root staff    173960 Feb 15 07:34 c-index-test
128320573 881388 -rwxr-xr-x  2 root staff 902535024 Feb 15 07:34 clang
130417228      0 lrwxrwxrwx  1 root staff         5 Feb 15 07:34 clang++ -> clang
128320575 372360 -rwxr-xr-x  2 root staff 381289744 Feb 15 07:34 clang-check
128320576  24032 -rwxr-xr-x  2 root staff  24608112 Feb 15 07:34 clang-format
128320577  10056 -rwxr-xr-x  2 root staff  10296048 Feb 15 07:34 clang-tblgen
128320578 584176 -rwxr-xr-x  2 root staff 598188352 Feb 15 07:36 cling
130417229      4 lrwxrwxrwx  1 root staff        71 Feb 13 19:19 configurable-http-proxy -> ../lib/node_modules/configurable-ht
tp-proxy/bin/configurable-http-proxy
128320579     12 -rwxr-xr-x  2 root staff     10512 Feb 15 07:34 count
128320580 335896 -rwxr-xr-x  2 root staff 343950448 Feb 15 07:34 llc
128320581 185036 -rwxr-xr-x  2 root staff 189469536 Feb 15 07:34 lli
128320582   3184 -rwxr-xr-x  2 root staff   3258360 Feb 15 07:34 lli-child-target
128320583  94312 -rwxr-xr-x  2 root staff  96571808 Feb 15 07:34 llvm-ar
128320584  26360 -rwxr-xr-x  2 root staff  26991696 Feb 15 07:34 llvm-as
128320585   3620 -rwxr-xr-x  2 root staff   3703464 Feb 15 07:34 llvm-bcanalyzer
128320586   2608 -rwxr-xr-x  2 root staff   2669080 Feb 15 07:34 llvm-config
128320587  30824 -rwxr-xr-x  2 root staff  31559952 Feb 15 07:34 llvm-cov
128320588  25292 -rwxr-xr-x  2 root staff  25898704 Feb 15 07:34 llvm-diff
128320589  22152 -rwxr-xr-x  2 root staff  22680880 Feb 15 07:34 llvm-dis
128320590  31384 -rwxr-xr-x  2 root staff  32136552 Feb 15 07:34 llvm-dsymutil
128320591  30520 -rwxr-xr-x  2 root staff  31250456 Feb 15 07:34 llvm-dwarfdump
128320592  34880 -rwxr-xr-x  2 root staff  35715608 Feb 15 07:34 llvm-extract
128320593  29940 -rwxr-xr-x  2 root staff  30657808 Feb 15 07:34 llvm-link
128320594  95972 -rwxr-xr-x  2 root staff  98271584 Feb 15 07:34 llvm-mc
128320595   3112 -rwxr-xr-x  2 root staff   3185544 Feb 15 07:34 llvm-mcmarkup
128320596  94240 -rwxr-xr-x  2 root staff  96498304 Feb 15 07:34 llvm-nm
128320597 104720 -rwxr-xr-x  2 root staff 107233024 Feb 15 07:34 llvm-objdump
128320598  18344 -rwxr-xr-x  2 root staff  18784128 Feb 15 07:34 llvm-profdata
130417230      0 lrwxrwxrwx  1 root staff         7 Feb 15 07:34 llvm-ranlib -> llvm-ar
128320600  36044 -rwxr-xr-x  2 root staff  36906032 Feb 15 07:34 llvm-readobj
128320601  68476 -rwxr-xr-x  2 root staff  70116312 Feb 15 07:34 llvm-rtdyld
128320602  32116 -rwxr-xr-x  2 root staff  32883424 Feb 15 07:34 llvm-size
128320603  23500 -rwxr-xr-x  2 root staff  24060896 Feb 15 07:34 llvm-stress
128320604  36152 -rwxr-xr-x  2 root staff  37016616 Feb 15 07:34 llvm-symbolizer
128320605  30804 -rwxr-xr-x  2 root staff  31540032 Feb 15 07:34 llvm-tblgen
128320606  34356 -rwxr-xr-x  2 root staff  35177976 Feb 15 07:34 llvm-vtabledump
128320607  31824 -rwxr-xr-x  2 root staff  32586496 Feb 15 07:34 macho-dump
128320608   2440 -rwxr-xr-x  2 root staff   2498344 Feb 15 07:34 not
128320609  34004 -rwxr-xr-x  2 root staff  34819160 Feb 15 07:34 obj2yaml
128320610 385896 -rwxr-xr-x  2 root staff 395149808 Feb 15 07:34 opt
128320611  28796 -rwxr-xr-x  2 root staff  29483520 Feb 15 07:34 verify-uselistorder
128320612   6256 -rwxr-xr-x  2 root staff   6405688 Feb 15 07:34 yaml2obj
 ---> 6c4325bfecb9
Removing intermediate container 89abc70b876b
Step 18 : RUN ls -lisa /usr/local/sbin
 ---> Running in 6d8f7881c28b
total 8
11183299 4 drwxrwsr-x  2 root staff 4096 Jan 25 15:18 .
11183298 4 drwxrwsr-x 11 root staff 4096 Feb 15 07:40 ..
 ---> 1c4e4903ed97
Removing intermediate container 6d8f7881c28b
Step 19 : RUN jupyter kernelspec install cling
 ---> Running in 7fd8ca918b30
Traceback (most recent call last):
  File "/opt/conda/bin/jupyter-kernelspec", line 8, in <module>
    main()
  File "/opt/conda/bin/jupyter-kernelspec", line 5, in main
    KernelSpecApp.launch_instance()
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/application.py", line 589, in launch_instance
    app.start()
  File "/opt/conda/lib/python3.5/site-packages/jupyter_client/kernelspecapp.py", line 209, in start
    return self.subapp.start()
  File "/opt/conda/lib/python3.5/site-packages/jupyter_client/kernelspecapp.py", line 138, in start
    replace=self.replace,
  File "/opt/conda/lib/python3.5/site-packages/jupyter_client/kernelspec.py", line 208, in install_kernel_spec
    shutil.copytree(source_dir, destination)
  File "/opt/conda/lib/python3.5/shutil.py", line 303, in copytree
    names = os.listdir(src)
FileNotFoundError: [Errno 2] No such file or directory: 'cling'
The command '/bin/sh -c jupyter kernelspec install cling' returned a non-zero code: 1

@ObiWahn
Copy link
Contributor

ObiWahn commented Feb 15, 2016

install

root@80692fd5f9da:/srv/cling-src/tools/cling/tools/Jupyter/kernel# pip install -e .                                                    
Obtaining file:///srv/cling-src/tools/cling/tools/Jupyter/kernel
Requirement already satisfied (use --upgrade to upgrade): ipykernel in /opt/conda/lib/python3.5/site-packages (from clingkernel==0.0.1)
Requirement already satisfied (use --upgrade to upgrade): traitlets in /opt/conda/lib/python3.5/site-packages (from clingkernel==0.0.1)
Installing collected packages: clingkernel
  Running setup.py develop for clingkernel
Successfully installed clingkernel
root@80692fd5f9da:/srv/cling-src/tools/cling/tools/Jupyter/kernel# jupyter kernelspec install cling
[InstallKernelSpec] Installed kernelspec cling in /usr/local/share/jupyter/kernels/cling

error

I 2016-02-15 19:42:10.054 obi handlers:170] Creating new notebook in 
[I 2016-02-15 19:42:10.063 obi sign:178] Writing notebook-signing key to /home/obi/.local/share/jupyter/notebook_secret
[W 2016-02-15 19:42:11.080 obi log:47] 404 GET /jupyter/user/obi/nbextensions/widgets/notebook/js/extension.js?v=20160215194205 (172.17.42.1) 7.28ms referer=http://localhost:8000/jupyter/user/obi/notebooks/Untitled.ipynb?kernel_name=cling
[I 2016-02-15 19:42:11.255 obi kernelmanager:89] Kernel started: e6e00760-b82a-4c8e-9f78-b12b1a120842
Traceback (most recent call last):
  File "/opt/conda/bin/jupyter-cling-kernel", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/scripts/jupyter-cling-kernel", line 4, in <module>
    main()
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/clingkernel.py", line 287, in main
    ClingKernelApp.launch_instance()
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/application.py", line 588, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-122>", line 2, in initialize
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/opt/conda/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 384, in initialize
    self.init_kernel()
  File "/opt/conda/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 323, in init_kernel
    user_ns=self.user_ns,
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/configurable.py", line 404, in instance
    inst = cls(*args, **kwargs)
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/clingkernel.py", line 84, in __init__
    if not self.libclingJupyter:
AttributeError: 'ClingKernel' object has no attribute 'libclingJupyter'
[I 2016-02-15 19:42:14.257 obi restarter:103] KernelRestarter: restarting kernel (1/5)
Traceback (most recent call last):
  File "/opt/conda/bin/jupyter-cling-kernel", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/scripts/jupyter-cling-kernel", line 4, in <module>
    main()
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/clingkernel.py", line 287, in main
    ClingKernelApp.launch_instance()
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/application.py", line 588, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-122>", line 2, in initialize
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/opt/conda/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 384, in initialize
    self.init_kernel()
  File "/opt/conda/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 323, in init_kernel
    user_ns=self.user_ns,
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/configurable.py", line 404, in instance
    inst = cls(*args, **kwargs)
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/clingkernel.py", line 84, in __init__
    if not self.libclingJupyter:
AttributeError: 'ClingKernel' object has no attribute 'libclingJupyter'
[I 2016-02-15 19:42:17.266 obi restarter:103] KernelRestarter: restarting kernel (2/5)
Traceback (most recent call last):
  File "/opt/conda/bin/jupyter-cling-kernel", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/scripts/jupyter-cling-kernel", line 4, in <module>
    main()
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/clingkernel.py", line 287, in main
    ClingKernelApp.launch_instance()
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/application.py", line 588, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-122>", line 2, in initialize
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/opt/conda/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 384, in initialize
    self.init_kernel()
  File "/opt/conda/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 323, in init_kernel
    user_ns=self.user_ns,
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/configurable.py", line 404, in instance
    inst = cls(*args, **kwargs)
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/clingkernel.py", line 84, in __init__
    if not self.libclingJupyter:
AttributeError: 'ClingKernel' object has no attribute 'libclingJupyter'
[I 2016-02-15 19:42:20.274 obi restarter:103] KernelRestarter: restarting kernel (3/5)
Traceback (most recent call last):
  File "/opt/conda/bin/jupyter-cling-kernel", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/scripts/jupyter-cling-kernel", line 4, in <module>
    main()
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/clingkernel.py", line 287, in main
    ClingKernelApp.launch_instance()
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/application.py", line 588, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-122>", line 2, in initialize
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/opt/conda/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 384, in initialize
    self.init_kernel()
  File "/opt/conda/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 323, in init_kernel
    user_ns=self.user_ns,
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/configurable.py", line 404, in instance
    inst = cls(*args, **kwargs)
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/clingkernel.py", line 84, in __init__
    if not self.libclingJupyter:
AttributeError: 'ClingKernel' object has no attribute 'libclingJupyter'
[W 2016-02-15 19:42:21.462 obi handlers:201] Timeout waiting for kernel_info reply from e6e00760-b82a-4c8e-9f78-b12b1a120842
[I 2016-02-15 19:42:23.282 obi restarter:103] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel e6e00760-b82a-4c8e-9f78-b12b1a120842 restarted
Traceback (most recent call last):
  File "/opt/conda/bin/jupyter-cling-kernel", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/scripts/jupyter-cling-kernel", line 4, in <module>
    main()
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/clingkernel.py", line 287, in main
    ClingKernelApp.launch_instance()
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/application.py", line 588, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-122>", line 2, in initialize
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/opt/conda/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 384, in initialize
    self.init_kernel()
  File "/opt/conda/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 323, in init_kernel
    user_ns=self.user_ns,
  File "/opt/conda/lib/python3.5/site-packages/traitlets/config/configurable.py", line 404, in instance
    inst = cls(*args, **kwargs)
  File "/srv/cling-src/tools/cling/tools/Jupyter/kernel/clingkernel.py", line 84, in __init__
    if not self.libclingJupyter:
AttributeError: 'ClingKernel' object has no attribute 'libclingJupyter'
[W 2016-02-15 19:42:26.290 obi restarter:95] KernelRestarter: restart failed
[W 2016-02-15 19:42:26.290 obi kernelmanager:54] Kernel e6e00760-b82a-4c8e-9f78-b12b1a120842 died, removing from map.
ERROR:root:kernel e6e00760-b82a-4c8e-9f78-b12b1a120842 restarted failed!
[W 2016-02-15 19:42:26.328 obi handlers:463] Kernel deleted before session
[W 2016-02-15 19:42:26.329 obi log:47] 410 DELETE /jupyter/user/obi/api/sessions/7f85a032-6547-4f4f-b307-3b67549657d1 (172.17.42.1) 1.12ms referer=http://localhost:8000/jupyter/user/obi/notebooks/Untitled.ipynb?kernel_name=cling
[I 2016-02-15 19:44:11.267 obi handlers:179] Saving file at /Untitled.ipynb

ObiWahn pushed a commit to obiwahn-abandoned/cling that referenced this issue Feb 15, 2016
@ulf1
Copy link
Author

ulf1 commented Feb 25, 2016

sorry for my late reply

source $locationofmyvirtualenv/bin/activate
cd $locationofcling/src/tools/cling/tools/Jupyter/kernel/
pip install -e .
jupyter kernelspec install --user cling

this works.

now i got the "libclingJupyter.dylib" error.
(I added cling to PATH)

@jhidding
Copy link

On Debian testing, somehow the libclingJupiter.so (or any other llvm installed .so file) doesn't have the executable flag set during install. This is what the Python module is checking using os.access(..., os.X_OK) on line 79 of clingkernel.py. For me doing

> for f in *.so; do chmod +x $f; done

in the $clingpath/lib directory fixes the issue.

@ObiWahn
Copy link
Contributor

ObiWahn commented Mar 19, 2016

I had fixed that in a pull request. The .so does not need the x flag. Fixing it like this is wrong. The python code should rather just check existence of a file.

Regards

On March 18, 2016 9:29:25 PM GMT+01:00, Johannes Hidding notifications@github.com wrote:

On Debian testing, somehow the libclingJupiter.so (or any other llvm
installed .so file) doesn't have the executable flag set during
install. This is what the Python module is checking using
os.access(..., os.X_OK) on line 79 of clingkernel.py. For me doing

for f in *.so; do chmod +x $f; done

in the $clingpath/lib directory fixes the issue.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#1 (comment)

Sent from my Android device with K-9 Mail. Please excuse my brevity.

@EHadoux
Copy link

EHadoux commented Apr 7, 2016

Hello, I am also fighting to make the kernel work.
Alongside all the error above I have one more which is:

[I 15:46:43.460 NotebookApp] KernelRestarter: restarting kernel (1/5)
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-cling-kernel", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/home/ehadoux/Softwares/cling_2016-04-07_ubuntu14/kernel/scripts/jupyter-cling-kernel", line 4, in <module>
    main()
  File "/home/ehadoux/Softwares/cling_2016-04-07_ubuntu14/kernel/clingkernel.py", line 287, in main
    ClingKernelApp.launch_instance()
  File "/home/ehadoux/.local/lib/python2.7/site-packages/traitlets/config/application.py", line 595, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-122>", line 2, in initialize
  File "/home/ehadoux/.local/lib/python2.7/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/ehadoux/.local/lib/python2.7/site-packages/ipykernel/kernelapp.py", line 421, in initialize
    self.init_kernel()
  File "/home/ehadoux/.local/lib/python2.7/site-packages/ipykernel/kernelapp.py", line 360, in init_kernel
    user_ns=self.user_ns,
  File "/home/ehadoux/.local/lib/python2.7/site-packages/traitlets/config/configurable.py", line 405, in instance
    inst = cls(*args, **kwargs)
  File "/home/ehadoux/Softwares/cling_2016-04-07_ubuntu14/kernel/clingkernel.py", line 70, in __init__
    whichCling = shutil.which('cling')
AttributeError: 'module' object has no attribute 'which'

Moreover, it does not seem possible to install the kernel using the binary package, only using the source from git, which is sad and constraining.

Thank you!

P.S.: I use the version of today.

@hellpanderrr
Copy link

@EHadoux
which was added in Python3
A possible solution (which I used):

        try:
            whichCling = shutil.which('cling')
        except AttributeError:
            from distutils.spawn import find_executable
            whichCling = find_executable('cling') 

@Axel-Naumann
Copy link
Member

Hi @EHadoux

Moreover, it does not seem possible to install the kernel using the binary package, only using the source from git, which is sad and constraining.

I totally agree. Would you be able to come up with a patch?

@Axel-Naumann
Copy link
Member

@hellpanderrr your patch from #1 (comment) is in. Thanks!

@Axel-Naumann
Copy link
Member

We have Issue #7 for the binary missing the Jupyter kernel. I believe the remaining issues are addressed. Closing...

Thanks to everyone for reporting, and esp to @ObiWahn for the PR!

@EHadoux
Copy link

EHadoux commented Apr 9, 2016

Hi,

I'm not quite sure what to do. I mean, isn't it enough to just have the tools directory into the tar?

Le 9 avr. 2016 à 09:40, Axel Naumann notifications@github.com a écrit :

Hi @EHadoux

Moreover, it does not seem possible to install the kernel using the binary package, only using the source from git, which is sad and constraining.

I totally agree. Would you be able to come up with a patch?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@Axel-Naumann
Copy link
Member

@EHadoux - let's continue the discussion in #7 but what's missing is the install step for the kernel's python code.

FonsRademakers pushed a commit that referenced this issue Oct 11, 2018
…transactions.

This fixes https://sft.its.cern.ch/jira/browse/ROOT-9672 by having
cling::Interpreter::DeclareCFunction return the transaction containing the
compiled code.

With the previous code, cling::Interpreter::compileFunction will get confused by
transaction created during the callbacks executed during the
cling::IncrementalParser::commitTransaction of the main transaction.

Reproducer:

With a main composed of 'only':

int main(int argc, char ** argv)
{
  char const * class_string = (argc == 2) ? argv[1] : "std::vector<int>";
  auto const result [[gnu::unused]] = TClass::GetClass(class_string);
  return 0;
}

which is a representation of real use case (in a more complex setup) in ART.
We were getting:

Error in <TClingCallFunc::make_wrapper>: Failed to compile
  ==== SOURCE BEGIN ====
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-security"
__attribute__((used)) extern "C" void __cf_0(void* obj, int nargs, void** args, void* ret)
{
   if (ret) {
      (*(TStreamerInfo**)ret) = new TStreamerInfo();
      return;
   }
   else {
      new TStreamerInfo();
      return;
   }
}
#pragma clang diagnostic pop
  ==== SOURCE END ====
Error in <TClingCallFunc::ExecT>: Called with no wrapper, not implemented!
Error in <TVirtualStreamerInfo::Factory>: The plugin handler for TVirtualStreamerInfo was found but failed to create the factory object!

The reason is that during TClingCallFunc::make_wrapper, the call to cling::Interpreter::compileFunction ends with:

    if (const llvm::GlobalValue* GV
        = getLastTransaction()->getModule()->getNamedValue(name))

However in the 'broken' case, the getLastTransaction does not return the transaction for the code being compiled by DeclareCFunction but instead the one used/created at:

#0  cling::IncrementalParser::endTransaction (this=0x4a2980, T=0x8c0fb0) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/interpreter/cling/lib/Interpreter/IncrementalParser.cpp:345
#1  0x00007fffeebc7899 in cling::Interpreter::PushTransactionRAII::pop (this=0x7fffffffcb00) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/interpreter/cling/lib/Interpreter/Interpreter.cpp:111
#2  0x00007fffeebc785e in cling::Interpreter::PushTransactionRAII::~PushTransactionRAII (this=0x7fffffffcb00, __in_chrg=<optimized out>)
    at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/interpreter/cling/lib/Interpreter/Interpreter.cpp:106
#3  0x00007fffeebeb659 in cling::LookupHelper::findScope (this=0x4a9dd0, className=..., diagOnOff=cling::LookupHelper::NoDiagnostics, resultType=0x7fffffffcd08, instantiateTemplate=false)
    at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/interpreter/cling/lib/Interpreter/LookupHelper.cpp:466
#4  0x00007fffeeabe0df in TCling::CheckClassInfo (this=0x4a0550, name=<optimized out>, autoload=<optimized out>, isClassOrNamespaceOnly=<optimized out>)
    at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/metacling/src/TCling.cxx:3630
#5  0x00007ffff7c3040d in TClass::Init (this=this@entry=0xdafd20, name=name@entry=0x7ffff7cb7638 "TGlobal", cversion=cversion@entry=2, typeinfo=typeinfo@entry=0x7ffff7d8b6d8 <typeinfo for TGlobal>, isa=isa@entry=0x477430,
    dfil=dfil@entry=0x7ffff7cb8cab "TGlobal.h", ifil=<optimized out>, dl=<optimized out>, il=<optimized out>, givenInfo=<optimized out>, silent=<optimized out>)
    at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/meta/src/TClass.cxx:1431
#6  0x00007ffff7c3a1b8 in TClass::TClass (this=0xdafd20, name=0x7ffff7cb7638 "TGlobal", cversion=<optimized out>, info=..., isa=0x477430, dfil=0x7ffff7cb8cab "TGlobal.h",
    ifil=0x7ffff7cccf88 "/local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/meta/src/TGlobal.cxx", dl=27, il=25, silent=false) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/meta/src/TClass.cxx:1273
#7  0x00007ffff7c3a72a in ROOT::CreateClass (cname=0x7ffff7cb7638 "TGlobal", id=id@entry=2, info=..., isa=isa@entry=0x477430, dfil=dfil@entry=0x7ffff7cb8cab "TGlobal.h",
    ifil=ifil@entry=0x7ffff7cccf88 "/local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/meta/src/TGlobal.cxx", dl=27, il=25) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/meta/src/TClass.cxx:5607
#8  0x00007ffff7c4b552 in ROOT::Internal::TDefaultInitBehavior::CreateClass (il=25, dl=27, ifil=0x7ffff7cccf88 "/local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/meta/src/TGlobal.cxx", dfil=0x7ffff7cb8cab "TGlobal.h",
    isa=0x477430, info=..., id=2, cname=<optimized out>, this=0x7ffff7da7508 <ROOT::Internal::DefineBehavior(void*, void*)::theDefault>) at /home/pcanal/root_builds/v6-14-00-patches/opt/include/Rtypes.h:176
#9  ROOT::TGenericClassInfo::GetClass (this=0x7ffff7dab660 <ROOT::GenerateInitInstanceLocal(TGlobal const*)::instance>) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/meta/src/TGenericClassInfo.cxx:250
#10 0x00007ffff7b1a2d8 in TGlobal::Class () at /home/pcanal/root_builds/v6-14-00-patches/opt/core/base/G__Core.cxx:17156
#11 0x00007ffff7ac01de in TGlobal::IsA (this=0xee3bc0) at /home/pcanal/root_builds/v6-14-00-patches/opt/include/TGlobal.h:48
#12 TGlobal::CheckTObjectHashConsistency (this=0xee3bc0) at /home/pcanal/root_builds/v6-14-00-patches/opt/include/TGlobal.h:48
#13 0x00007ffff7be9dcd in TObject::CheckedHash (this=0xee3bc0) at /home/pcanal/root_builds/v6-14-00-patches/opt/include/TObject.h:314
#14 THashTable::GetCheckedHashValue (this=0xe65a20, obj=0xee3bc0) at /home/pcanal/root_builds/v6-14-00-patches/opt/include/THashTable.h:94
#15 THashTable::Add (this=0xe65a20, obj=0xee3bc0) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/cont/src/THashTable.cxx:96
#16 0x00007ffff7be6bf1 in THashList::AddLast (this=this@entry=0x5be690, obj=obj@entry=0xee3bc0) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/cont/src/THashList.cxx:100
#17 0x00007ffff7c4e0d1 in TListOfDataMembers::AddLast (this=0x5be690, obj=0xee3bc0) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/meta/src/TListOfDataMembers.cxx:103
#18 0x00007ffff7ab8785 in TList::Add (obj=0xee3bc0, this=0x5be690) at /home/pcanal/root_builds/v6-14-00-patches/opt/include/TList.h:87
#19 TROOT::GetListOfGlobals (this=0x7ffff7da7a60 <ROOT::Internal::GetROOT1()::alloc>, load=load@entry=false) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/base/src/TROOT.cxx:1767
#20 0x00007fffeeab1058 in TCling::HandleNewDecl (this=0x4a0550, DV=0xedf238, isDeserialized=isDeserialized@entry=true, modifiedTClasses=...) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/metacling/src/TCling.cxx:555
#21 0x00007fffeeabb785 in TCling::UpdateListsOnCommitted (this=0x4a0550, T=...) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/metacling/src/TCling.cxx:6115
#22 0x00007fffeebd0103 in cling::MultiplexInterpreterCallbacks::TransactionCommitted (this=0x57fe20, T=...) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/interpreter/cling/lib/Interpreter/MultiplexInterpreterCallbacks.h:76
#23 0x00007fffeed05d71 in cling::IncrementalParser::commitTransaction (this=0x4a2980, PRT=..., ClearDiagClient=true) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/interpreter/cling/lib/Interpreter/IncrementalParser.cpp:532
#24 0x00007fffeed06399 in cling::IncrementalParser::Compile (this=0x4a2980, input=..., Opts=...) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/interpreter/cling/lib/Interpreter/IncrementalParser.cpp:663
#25 0x00007fffeebcbc4e in cling::Interpreter::DeclareInternal (this=0x4a0f30, input=..., CO=..., T=0x7fffffffd680) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/interpreter/cling/lib/Interpreter/Interpreter.cpp:1195
#26 0x00007fffeebca8e8 in cling::Interpreter::declare (this=0x4a0f30, input=..., T=0x7fffffffd680) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/interpreter/cling/lib/Interpreter/Interpreter.cpp:823
#27 0x00007fffeebcb560 in cling::Interpreter::DeclareCFunction (this=0x4a0f30, name=..., code=..., withAccessControl=true) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/interpreter/cling/lib/Interpreter/Interpreter.cpp:1096
#28 0x00007fffeebcb862 in cling::Interpreter::compileFunction (this=0x4a0f30, name=..., code=..., ifUnique=false, withAccessControl=true)
    at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/interpreter/cling/lib/Interpreter/Interpreter.cpp:1140
#29 0x00007fffeeafb83c in TClingCallFunc::compile_wrapper (withAccessControl=true, wrapper=..., wrapper_name=..., this=0xcf3c10) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/metacling/src/TClingCallFunc.cxx:270
#30 TClingCallFunc::make_wrapper (this=this@entry=0xcf3c10) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/metacling/src/TClingCallFunc.cxx:1096
#31 0x00007fffeeafbcb8 in TClingCallFunc::IFacePtr (this=this@entry=0xcf3c10) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/metacling/src/TClingCallFunc.cxx:2233
#32 0x00007fffeeafbe83 in TClingCallFunc::ExecT<long> (address=0x0, this=0xcf3c10) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/metacling/src/TClingCallFunc.cxx:2045
#33 TClingCallFunc::ExecInt (this=0xcf3c10, address=0x0) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/metacling/src/TClingCallFunc.cxx:2065
#34 0x00007ffff7c56e8d in TMethodCall::Execute (this=0xd97710, object=<optimized out>, retLong=@0x7fffffffd958: 0) at /local2/pcanal/cint_working/rootcling/v6-14-00-patches/core/meta/src/TMethodCall.cxx:457
#35 0x0000000000401009 in TMethodCall::Execute(long&) ()
#36 0x00000000004010ea in long TPluginHandler::ExecPluginImpl<>() ()
#37 0x000000000040106d in long TPluginHandler::ExecPlugin<>(int) ()
#38 0x0000000000400e21 in mytest() ()
#39 0x0000000000400e92 in main ()
FonsRademakers pushed a commit that referenced this issue May 5, 2021
Before, MetaParser might have pointed to a StringRef whose storage
was gone, see asan failure in roottest/cling/other/runfileClose.C below.

This was caused by recursive uses of MetaParser; see stack trace below:
the inner recursion returned, but as the same MetaParser object was used
by both frames, the objects cursor now pointed to freed memory.

Instead, create a MetaParser (and MetaLexer) object per input. That way,
their lifetime corresponds to the lifetime of their input.

=================================================================
==529104==ERROR: AddressSanitizer: stack-use-after-return on address 0x7ffff3afd82a at pc 0x7fffea18df6d bp 0x7fffffff8170 sp 0x7fffffff8168
READ of size 1 at 0x7ffff3afd82a thread T0
[Detaching after fork from child process 529183]
    #0 0x7fffea18df6c in cling::MetaLexer::Lex(cling::Token&) src/interpreter/cling/lib/MetaProcessor/MetaLexer.cpp:58:11
    #1 0x7fffea190d7c in cling::MetaParser::lookAhead(unsigned int) src/interpreter/cling/lib/MetaProcessor/MetaParser.cpp:89:15
    #2 0x7fffea190bd5 in cling::MetaParser::consumeToken() src/interpreter/cling/lib/MetaProcessor/MetaParser.cpp:49:5
    #3 0x7fffea191d4d in cling::MetaParser::isLCommand(cling::MetaSema::ActionResult&) src/interpreter/cling/lib/MetaProcessor/MetaParser.cpp:147:9
    #4 0x7fffea1914dd in cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) src/interpreter/cling/lib/MetaProcessor/MetaParser.cpp:123:12
    #5 0x7fffea191216 in cling::MetaParser::isMetaCommand(cling::MetaSema::ActionResult&, cling::Value*) src/interpreter/cling/lib/MetaProcessor/MetaParser.cpp:101:33
    #6 0x7fffea14e5aa in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) src/interpreter/cling/lib/MetaProcessor/MetaProcessor.cpp:317:24
    #7 0x7fffe99b67b7 in HandleInterpreterException(cling::MetaProcessor*, char const*, cling::Interpreter::CompilationResult&, cling::Value*) src/core/metacling/src/TCling.cxx:2431:29
    #8 0x7fffe99bde30 in TCling::Load(char const*, bool) src/core/metacling/src/TCling.cxx:3454:10
    #9 0x7ffff7865f11 in TSystem::Load(char const*, char const*, bool) src/core/base/src/TSystem.cxx:1941:27
    #10 0x7ffff7b8a0e3 in TUnixSystem::Load(char const*, char const*, bool) src/core/unix/src/TUnixSystem.cxx:2789:20
    #11 0x7fffd78dd08b  (<unknown module>)
    #12 0x7fffe9f8a5d9 in cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const src/interpreter/cling/lib/Interpreter/IncrementalExecutor.cpp:376:3
    #13 0x7fffe9d73dc2 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) src/interpreter/cling/lib/Interpreter/Interpreter.cpp:1141:20
    #14 0x7fffe9d6e317 in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) src/interpreter/cling/lib/Interpreter/Interpreter.cpp:1391:29
    #15 0x7fffe9d6c1fe in cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) src/interpreter/cling/lib/Interpreter/Interpreter.cpp:819:9
    #16 0x7fffea151826 in cling::MetaProcessor::readInputFromFile(llvm::StringRef, cling::Value*, unsigned long, bool) src/interpreter/cling/lib/MetaProcessor/MetaProcessor.cpp:507:22
    #17 0x7fffe99b585b in TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) src/core/metacling/src/TCling.cxx:2570:39
    #18 0x7fffe99bbfee in TCling::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) src/core/metacling/src/TCling.cxx:3496:17
    #19 0x7ffff77203d3 in TApplication::ExecuteFile(char const*, int*, bool) src/core/base/src/TApplication.cxx:1608:30
    #20 0x7ffff771ebdf in TApplication::ProcessFile(char const*, int*, bool) src/core/base/src/TApplication.cxx:1480:11
    #21 0x7ffff771e385 in TApplication::ProcessLine(char const*, bool, int*) src/core/base/src/TApplication.cxx:1453:14
    #22 0x7ffff7f8157a in TRint::ProcessLineNr(char const*, char const*, int*) src/core/rint/src/TRint.cxx:766:11
    #23 0x7ffff7f802f0 in TRint::Run(bool) src/core/rint/src/TRint.cxx:424:22
    #24 0x4ff96d in main src/main/src/rmain.cxx:30:12
    #25 0x7ffff6e040b2 in __libc_start_main /build/glibc-YbNSs7/glibc-2.31/csu/../csu/libc-start.c:308:16
    #26 0x41f35d in _start (asan/bin/root.exe+0x41f35d)

Address 0x7ffff3afd82a is located in stack of thread T0 at offset 42 in frame
    #0 0x7fffe99b3d8f in TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) src/core/metacling/src/TCling.cxx:2456

  This frame has 21 object(s):
    [32, 56) 'sLine' (line 2462) <== Memory access at offset 42 is inside this variable
    [96, 104) 'R__guard2471' (line 2471)
    [128, 136) 'R__guard2488' (line 2488)
    [160, 176) 'interpreterFlagsRAII' (line 2491)
    [192, 240) 'result' (line 2511)
    [272, 276) 'compRes' (line 2512)
    [288, 312) 'mod_line' (line 2517)
    [352, 376) 'aclicMode' (line 2518)
    [416, 440) 'arguments' (line 2519)
    [480, 504) 'io' (line 2520)
    [544, 568) 'fname' (line 2521)
    [608, 632) 'ref.tmp' (line 2547)
    [672, 696) 'ref.tmp145' (line 2547)
    [736, 768) 'code' (line 2555)
    [800, 832) 'codeline' (line 2556)
    [864, 1384) 'in' (line 2559)
    [1520, 1552) 'ref.tmp176' (line 2562)
    [1584, 1600) 'agg.tmp'
    [1616, 1624) 'ref.tmp198' (line 2568)
    [1648, 1664) 'agg.tmp207'
    [1680, 1696) 'autoParseRaii' (line 2588)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-use-after-return src/interpreter/cling/lib/MetaProcessor/MetaLexer.cpp:58:11 in cling::MetaLexer::Lex(cling::Token&)
Shadow bytes around the buggy address:
  0x10007e757ab0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757ac0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757ad0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757ae0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757af0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
=>0x10007e757b00: f5 f5 f5 f5 f5[f5]f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757b10: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757b20: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757b30: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757b40: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x10007e757b50: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==529104==ABORTING

    at src/interpreter/cling/lib/MetaProcessor/MetaLexer.cpp:49
    at src/interpreter/cling/lib/MetaProcessor/MetaParser.cpp:41
    compRes=@0x7ffff3afd910: cling::Interpreter::kSuccess, result=0x7ffff3afd8c0, disableValuePrinting=false)
    at src/interpreter/cling/lib/MetaProcessor/MetaProcessor.cpp:314
    input_line=0x7ffff3afd829 "#define XYZ 21", compRes=@0x7ffff3afd910: cling::Interpreter::kSuccess,
    result=0x7ffff3afd8c0) at src/core/metacling/src/TCling.cxx:2431
    error=0x7fffd78cb0f4 <x>) at src/core/metacling/src/TCling.cxx:2591
    sync=false, err=0x7fffd78cb0f4 <x>) at src/core/base/src/TApplication.cxx:1472
    line=0x7fffd78c9000 "#define XYZ 21", error=0x7fffd78cb0f4 <x>)
    at src/core/base/src/TROOT.cxx:2328
   from asan/roottest/cling/other/fileClose_C.so
    filename=0x6070000f0fd0 "asan/roottest/cling/other/fileClose_C.so", flag=257)
    at /home/axel/build/llvm/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:6270
    at src/interpreter/cling/lib/Utils/PlatformPosix.cpp:118
    permanent=false, resolved=true)
    at src/interpreter/cling/lib/Interpreter/DynamicLibraryManager.cpp:184
    at src/interpreter/cling/lib/Interpreter/Interpreter.cpp:1444
    T=0x0) at src/interpreter/cling/lib/Interpreter/Interpreter.cpp:1560
    at src/interpreter/cling/lib/MetaProcessor/MetaSema.cpp:57
    actionResult=@0x7ffff39532b0: cling::MetaSema::AR_Success)
FonsRademakers pushed a commit that referenced this issue Dec 9, 2022
Fixes root-meta-execUnloading which shows
```==768591== Invalid read of size 8
==768591==    at 0x6EFB10E: llvm::ilist_node_base<false>::getNext() const (ilist_node_base.h:29)
==768591==    by 0x6FBF119: llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Function, false, false, void> >::getNext() (ilist_node.h:66)
==768591==    by 0x6FBED48: llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, false, false, void>, false, false>::operator++() (ilist_iterator.h:157)
==768591==    by 0x6FBEA20: llvm::simple_ilist<llvm::Function>::begin() (simple_ilist.h:117)
==768591==    by 0x6FBE40F: llvm::Module::begin() (Module.h:622)
==768591==    by 0x6FBE475: llvm::Module::functions() (Module.h:634)
==768591==    by 0x6FBE22F: cling::TransactionUnloader::unloadModule(llvm::Module*) (TransactionUnloader.cpp:175)
==768591==    by 0x6FBDF83: cling::TransactionUnloader::RevertTransaction(cling::Transaction*) (TransactionUnloader.cpp:126)
==768591==    by 0x6F90CD0: cling::Interpreter::unload(cling::Transaction&) (Interpreter.cpp:1553)
==768591==    by 0x6F90E25: cling::Interpreter::unload(unsigned int) (Interpreter.cpp:1574)
==768591==    by 0x721A9F2: cling::MetaSema::actOnUndoCommand(unsigned int) (MetaSema.cpp:186)
```
...
```
==768591==  Address 0x144b0ce0 is 32 bytes inside a block of size 800 free'd
==768591==    at 0x484399B: operator delete(void*, unsigned long) (vg_replace_malloc.c:935)
==768591==    by 0x6FBC7CA: std::default_delete<llvm::Module>::operator()(llvm::Module*) const (unique_ptr.h:95)
==768591==    by 0x6FBC82D: std::__uniq_ptr_impl<llvm::Module, std::default_delete<llvm::Module> >::reset(llvm::Module*) (unique_ptr.h:203)
==768591==    by 0x6FBC87E: std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >::reset(llvm::Module*) (unique_ptr.h:501)
==768591==    by 0x6FBC04E: std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >::operator=(decltype(nullptr)) (unique_ptr.h:434)
==768591==    by 0x70E60E7: llvm::orc::ThreadSafeModule::~ThreadSafeModule() (ThreadSafeModule.h:116)
==768591==    by 0x936EC79: llvm::orc::IRMaterializationUnit::~IRMaterializationUnit() (Layer.h:31)
==768591==    by 0x93707F5: llvm::orc::BasicIRLayerMaterializationUnit::~BasicIRLayerMaterializationUnit() (Layer.h:121)
==768591==    by 0x9370811: llvm::orc::BasicIRLayerMaterializationUnit::~BasicIRLayerMaterializationUnit() (Layer.h:121)
==768591==    by 0x6E91B45: std::default_delete<llvm::orc::MaterializationUnit>::operator()(llvm::orc::MaterializationUnit*) const (unique_ptr.h:95)
==768591==    by 0x6E8F9A3: std::unique_ptr<llvm::orc::MaterializationUnit, std::default_delete<llvm::orc::MaterializationUnit> >::~unique_ptr() (unique_ptr.h:396)
==768591==    by 0x935D3C3: llvm::orc::JITDylib::UnmaterializedInfo::~UnmaterializedInfo() (Core.h:1062)
==768591==    by 0x935D3DE: void std::_Destroy<llvm::orc::JITDylib::UnmaterializedInfo>(llvm::orc::JITDylib::UnmaterializedInfo*) (stl_construct.h:151)
==768591==    by 0x935D26B: void std::allocator_traits<std::allocator<void> >::destroy<llvm::orc::JITDylib::UnmaterializedInfo>(std::allocator<void>&, llvm::orc::JITDylib::UnmaterializedInfo*) (alloc_traits.h:648)
==768591==    by 0x935CBA0: std::_Sp_counted_ptr_inplace<llvm::orc::JITDylib::UnmaterializedInfo, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (shared_ptr_base.h:613)
==768591==    by 0x6C39FCE: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:346)
==768591==    by 0x6C3CB36: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() (shared_ptr_base.h:1071)
==768591==    by 0x6E98CED: std::__shared_ptr<llvm::orc::JITDylib::UnmaterializedInfo, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() (shared_ptr_base.h:1524)
==768591==    by 0x6E98D09: std::shared_ptr<llvm::orc::JITDylib::UnmaterializedInfo>::~shared_ptr() (shared_ptr.h:175)
==768591==    by 0x932D614: llvm::DenseMapBase<llvm::DenseMap<llvm::orc::SymbolStringPtr, std::shared_ptr<llvm::orc::JITDylib::UnmaterializedInfo>, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr>, llvm::detail::DenseMapPair<llvm::orc::SymbolStringPtr, std::shared_ptr<llvm::orc::JITDylib::UnmaterializedInfo> > >, llvm::orc::SymbolStringPtr, std::shared_ptr<llvm::orc::JITDylib::UnmaterializedInfo>, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr>, llvm::detail::DenseMapPair<llvm::orc::SymbolStringPtr, std::shared_ptr<llvm::orc::JITDylib::UnmaterializedInfo> > >::erase(llvm::orc::SymbolStringPtr const&) (DenseMap.h:307)
==768591==    by 0x931028D: llvm::orc::JITDylib::removeTracker(llvm::orc::ResourceTracker&) (Core.cpp:1510)
==768591==    by 0x9315060: llvm::orc::ExecutionSession::removeResourceTracker(llvm::orc::ResourceTracker&)::{lambda()#1}::operator()() const (Core.cpp:2155)
==768591==    by 0x93150D0: decltype(auto) llvm::orc::ExecutionSession::runSessionLocked<llvm::orc::ExecutionSession::removeResourceTracker(llvm::orc::ResourceTracker&)::{lambda()#1}>(llvm::orc::ExecutionSession::removeResourceTracker(llvm::orc::ResourceTracker&)::{lambda()#1}&&) (Core.h:1326)
==768591==    by 0x9315272: llvm::orc::ExecutionSession::removeResourceTracker(llvm::orc::ResourceTracker&) (Core.cpp:2152)
==768591==    by 0x93060FD: llvm::orc::ResourceTracker::remove() (Core.cpp:53)
==768591==    by 0x70F1D58: cling::IncrementalJIT::removeModule(cling::Transaction const&) (IncrementalJIT.cpp:151)
==768591==    by 0x6FBE6CF: cling::IncrementalExecutor::unloadModule(cling::Transaction const&) const (IncrementalExecutor.h:180)
==768591==    by 0x6FBDE5B: cling::TransactionUnloader::RevertTransaction(cling::Transaction*) (TransactionUnloader.cpp:119)
==768591==    by 0x6F90CD0: cling::Interpreter::unload(cling::Transaction&) (Interpreter.cpp:1553)
==768591==    by 0x6F90E25: cling::Interpreter::unload(unsigned int) (Interpreter.cpp:1574)
==768591==    by 0x721A9F2: cling::MetaSema::actOnUndoCommand(unsigned int) (MetaSema.cpp:186)
```
@cpp-deep-learning cpp-deep-learning mentioned this issue Feb 24, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants