ROOTaaS C++ kernel sdtout or stderr malformed message with zmq

I am testing for the first time the nice idea of ROOTaaS. I have installed ROOT v6.07/02, python 2.7.11, jupyter 4.0.6, Mozilla Iceweasel 44.0 on Debian sid.

I followed the instructions https://root.cern.ch/how/how-create-rootbook and started as

Then, I open a Python2 notebook, make a simple test, that works perfectly:

[code]In [1]: import ROOT
Welcome to JupyROOT 6.07/02

In [2]:
%%cpp
TFile* aFile = TFile::Open(“u100.root”);
aFile->ls();
TFile** u100.root
TFile* u100.root
KEY: TTree data;5 read from binary file
KEY: TMacro u100-p0008;1 console.log[/code]

I try then the C++ Kernel directly, and write just this.

TFile* aFile = TFile::Open("u100.root"); aFile->ls();
This does not work. It seems that I missed something, because I get the following error printed in the terminal (not in the notebook):

root --notebook [I 17:32:38.833 NotebookApp] Serving notebooks from local directory: /home/MED/ferhue [I 17:32:38.834 NotebookApp] 0 active kernels [I 17:32:38.834 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/ [I 17:32:38.834 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [I 17:32:44.195 NotebookApp] Kernel started: 05971c39-1039-4cbf-b5a8-0727b692b7e5 [C 17:32:51.151 NotebookApp] Malformed message: ['<IDS|MSG>', '6b071c5a030d7cf0b65b640c9295f52d437f3a443de728cdec359284ece37b8e', '{"username":"ferhue","msg_type":"stream","msg_id":"a9507291-9721-499f-89d1-105bfbfb442e","version":"5.0","session":"111a00c1-f7a9-4927-ac97-2bc379f092ed","date":"2016-02-08T17:32:51.146912"}', '{"username":"username","version":"5.0","msg_type":"execute_request","msg_id":"211BFFAC3DC04FA884C67B93EC3E69DD","session":"4FEAC7B1148F48C2870E85F54A71BD28","date":"2016-02-08T17:32:50.920828"}', '{}', '{"text":"X\\\\Z\xaf\\u0004\x7f","name":"stdout"}'] Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/notebook/base/zmqhandlers.py", line 249, in _on_zmq_reply msg = self._reserialize_reply(msg_list, channel=channel) File "/usr/local/lib/python2.7/dist-packages/notebook/base/zmqhandlers.py", line 230, in _reserialize_reply msg = self.session.deserialize(msg_list) File "/usr/local/lib/python2.7/dist-packages/jupyter_client/session.py", line 859, in deserialize message['content'] = self.unpack(msg_list[4]) File "/usr/local/lib/python2.7/dist-packages/jupyter_client/session.py", line 97, in <lambda> json_unpacker = lambda s: jsonapi.loads(s) File "/usr/local/lib/python2.7/dist-packages/zmq/utils/jsonapi.py", line 56, in loads return jsonmod.loads(s, **kwargs) File "/usr/lib/python2.7/json/__init__.py", line 339, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 364, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/json/decoder.py", line 380, in raw_decode obj, end = self.scan_once(s, idx) UnicodeDecodeError: 'utf8' codec can't decode byte 0xaf in position 1: invalid start byte

It seems that stdout as well as stderr are not correctly redirected by zmq to the notebook. Maybe my python or jupyter version is too old? I would appreciate any hint. I found this, maybe it helps:
https://github.com/JuliaLang/ZMQ.jl/issues/73

Thanks, and congratulations for this new feature and all your work.

Hi,

thanks for your report.
I just tried master and Jupyter 4.0.6 and cannot reproduce the issue.
I have three question which could help us make some progress:

  1. How did you install ROOT on Debian?
  2. Can you confirm that the kernel was in “ready” state when running the cell?
  3. Can you try on your very setup the ROOT master?

Cheers,
Danilo

cd /opt git clone http://root.cern.ch/git/root.git root6_src cd root6_src git checkout -b v6-07-02 v6-07-02 cd - mkdir root6_bld cd root6_bld cmake -Droofit=true -Dhttp=true /opt/root6_src cmake --build . mkdir ../root6_inst cmake -DCMAKE_INSTALL_PREFIX=/opt/root6_inst -P cmake_install.cmake cd source /opt/root6_inst/bin/thisroot.sh root --notebook
(Not sure if inst and bld could be the same directory?)

Yes, the kernel was ready. I checked that. The error appears when ROOT tried to print to terminal. Otherwise doing y=x+3; worked without error.

What do you mean? Not checking out the 6-07-02 branch?

Thanks for the information. About 3), yes, checking out the master: this could show us if there is something we can do to the environment.

Cheers,
Danilo

I tried with the master, but I get a compilation error with cmake, saying that it does not support gcc 5.3.

sft.its.cern.ch/jira/browse/ROOT-7947

Yes,
this is known to us and will be fixed.
Can you build with gcc49 or with the old abi?

D

Thanks for the hint. I just tried, but I am not sure if I am missing some flags for clang or sth else. I did:

cd /opt/root607
cmake -Droofit=true -Dhttp=true -DCMAKE_CXX_COMPILER=g++-4.8 -DCMAKE_C_COMPILER=gcc-4.8 /opt/root6
cmake --build .
source /opt/root607/bin/thisroot.sh
root --notebook

I get know some weird errors, now printed in the notebook instead of the terminal (i.e. the zmq handler error is gone):

TFile* aFile = TFile::Open("u100.root");
aFile->ls();
input_line_30:3:1: error: cannot cast from type 'void' to pointer type 'const TFile *'
aFile->ls();
^~~~~

 *** Break *** segmentation violation

ROOT C++ kernel restarts after the error message:

root --notebook
[I 17:08:20.893 NotebookApp] Serving notebooks from local directory: /home/MED/ferhue
[I 17:08:20.893 NotebookApp] 0 active kernels 
[I 17:08:20.893 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 17:08:20.893 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 17:08:29.055 NotebookApp] Kernel started: 70dceb42-7bdd-4c73-bd58-76256bd077f9
[I 17:08:38.052 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 70dceb42-7bdd-4c73-bd58-76256bd077f9 restarted

I tested the same notebook in another computer with gcc 4.9 and master, and it works. So I think I did something wrong with the flags…

Ok, I managed to build ROOT6 master (6.07.03) in Debian stretch (sid), by downgrading first the default gcc compiler (5.3) to 4.8. Now all error messages about ABIs, zmq and so on have disappeared.

I did this with the update-alternatives method described here: http://askubuntu.com/a/26518. I post the complete workflow, in case someone has the same problem.

sudo apt-get install git dpkg-dev make g++ gcc binutils libx11-dev libxpm-dev \
libxft-dev libxext-dev
sudo apt-get install gfortran libssl-dev libpcre3-dev \
xlibmesa-glu-dev libglew1.5-dev libftgl-dev \
libmysqlclient-dev libfftw3-dev cfitsio-dev \
graphviz-dev libavahi-compat-libdnssd-dev \
libldap2-dev python-dev libxml2-dev libkrb5-dev \
libgsl0-dev libqt4-dev ccache

sudo update-alternatives --remove-all g++
sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all gfortran 
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 20
sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-4.8 10
sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-5 20
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
sudo update-alternatives --config gfortran

sudo mkdir /opt/root6
sudo chown myusername /opt/root6
#No need to use sudo anymore.
#Alternatively, just do mkdir /home/myuser/root6 and replace below all /opt/root6
cd /opt/root6
git clone http://root.cern.ch/git/root.git root6_src
cmake -Droofit=ON -Dhttp=ON -Dccache=ON /opt/root6/root6_src/
cmake --build .
#or make -j8 instead
source /opt/root6/bin/thisroot.sh
# Or add previous line in your ~/.bashrc
root --notebook

Hi,

thanks a lot for your efforts.
It is still unclear to me what could cause the problem in the first place but I’ll see what I can do in terms of backporting the fixes which are in master.
In any case, a development release should be available soon.

Cheers,
Danilo