jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.72k stars 4.95k forks source link

Segmentation fault when using %%sh magic with call to python3 #3017

Open toobaz opened 7 years ago

toobaz commented 7 years ago

If I create a notebook with one cell only, containing the following:

%%sh
python3 -m pip install --user jupyter_contrib_nbextensions

and run it, the server segfaults, producing the following stack trace:

``` pietro@debiousci:~$ gdb python3 GNU gdb (Debian 7.12-6) 7.12.0.20161007-git Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from python3...Reading symbols from /usr/lib/debug/.build-id/db/fc2e1a3c58b6d241b3f9af7b2fb3a24b81b90e.debug...done. done. (gdb) r ~/.local/bin/jupyter-notebook Starting program: /usr/bin/python3 ~/.local/bin/jupyter-notebook [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [I 15:08:07.970 NotebookApp] The port 8888 is already in use, trying another port. [I 15:08:07.970 NotebookApp] The port 8889 is already in use, trying another port. [I 15:08:07.971 NotebookApp] The port 8890 is already in use, trying another port. [I 15:08:07.978 NotebookApp] Serving notebooks from local directory: /home/pietro [I 15:08:07.978 NotebookApp] 0 active kernels [I 15:08:07.978 NotebookApp] The Jupyter Notebook is running at: [I 15:08:07.978 NotebookApp] http://localhost:8891/?token=d6ed4034f5efea326916bff9e2df0ecdcdc298ab71723904 [I 15:08:07.978 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [New Thread 0x7fffee04e700 (LWP 16671)] [C 15:08:07.981 NotebookApp] Copy/paste this URL into your browser when you connect for the first time, to login with a token: http://localhost:8891/?token=d6ed4034f5efea326916bff9e2df0ecdcdc298ab71723904 Chiamato [W 15:08:08.247 NotebookApp] 404 GET /api/kernels/622453ab-799d-402e-be71-b358a7667677/channels?session_id=084EABFE1F8E4ADF8F1C93AD4AE98BED (::1): Kernel does not exist: 622453ab-799d-402e-be71-b358a7667677 [W 15:08:08.280 NotebookApp] 404 GET /api/kernels/622453ab-799d-402e-be71-b358a7667677/channels?session_id=084EABFE1F8E4ADF8F1C93AD4AE98BED (::1) 42.96ms referer=None Gtk-Message: Failed to load module "canberra-gtk-module" Created new window in existing browser session. [16673:16716:1104/150808.413463:ERROR:nss_util.cc(747)] After loading Root Certs, loaded==false: NSS error code: -8018 [16673:16716:1104/150808.415055:ERROR:browser_gpu_channel_host_factory.cc(103)] Failed to launch GPU process. [Thread 0x7fffee04e700 (LWP 16671) exited] [I 15:08:08.494 NotebookApp] Accepting one-time-token-authenticated connection from ::1 [W 15:08:48.938 NotebookApp] 404 GET /nbextensions/contrib.js?v=20171104150807 (::1) 2.73ms referer=http://localhost:8891/notebooks/notebook/Untitled7.ipynb [W 15:08:48.941 NotebookApp] 404 GET /nbextensions/nbextensions_configurator.js?v=20171104150807 (::1) 2.40ms referer=http://localhost:8891/notebooks/notebook/Untitled7.ipynb [New Thread 0x7fffee04e700 (LWP 16778)] [New Thread 0x7fffed58d700 (LWP 16779)] [I 15:08:49.039 NotebookApp] Kernel started: 452ab64a-dc69-4dff-9e7d-be88d228c881 [W 15:08:49.132 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20171104150807 (::1) 10.25ms referer=http://localhost:8891/notebooks/notebook/Untitled7.ipynb [I 15:08:49.965 NotebookApp] Adapting to protocol v5.1 for kernel 452ab64a-dc69-4dff-9e7d-be88d228c881 Thread 1 "python3" received signal SIGSEGV, Segmentation fault. 0x000000000000c746 in ?? () (gdb) backtrace #0 0x000000000000c746 in ?? () #1 0x00007ffff36a92a8 in zmq_poll (items_=items_@entry=0x555556d56b40, nitems_=nitems_@entry=14, timeout_=timeout_@entry=2998) at src/zmq.cpp:776 #2 0x00007ffff21a5d24 in __pyx_pf_3zmq_7backend_6cython_5_poll_zmq_poll ( __pyx_v_sockets=__pyx_v_sockets@entry=[(6, 5), (4, 5), (5, 5), (8, 5), (9, 5), (10, 5), (11, 5), (12, 5), (13, 5), (, 5), (27, 5), (, 5), (, 5), (, 5)], __pyx_v_timeout=2998, __pyx_self=) at zmq/backend/cython/_poll.c:2149 #3 0x00007ffff21a7eb0 in __pyx_pw_3zmq_7backend_6cython_5_poll_1zmq_poll ( __pyx_self=, __pyx_args=, __pyx_kwds=) at zmq/backend/cython/_poll.c:1521 #4 0x000055555575d647 in PyObject_Call () at ../Objects/abstract.c:2166 #5 0x00005555556d4ee1 in do_call (nk=, na=1, pp_stack=0x7fffffffcea0, func=) at ../Python/ceval.c:4951 #6 call_function (oparg=, pp_stack=0x7fffffffcea0) at ../Python/ceval.c:4747 #7 PyEval_EvalFrameEx () at ../Python/ceval.c:3251 #8 0x00005555556d9286 in _PyEval_EvalCodeWithName () at ../Python/ceval.c:4033 #9 0x00005555556d50a9 in fast_function (nk=, na=, n=, pp_stack=0x7fffffffd0b0, func=) at ../Python/ceval.c:4828 #10 call_function (oparg=, pp_stack=0x7fffffffd0b0) at ../Python/ceval.c:4745 #11 PyEval_EvalFrameEx () at ../Python/ceval.c:3251 #12 0x00005555556d97bf in _PyEval_EvalCodeWithName () at ../Python/ceval.c:4033 #13 0x00005555556d54c9 in fast_function (nk=, na=, n=, pp_stack=0x7fffffffd2c0, func=) at ../Python/ceval.c:4828 #14 call_function (oparg=, pp_stack=0x7fffffffd2c0) at ../Python/ceval.c:4745 #15 PyEval_EvalFrameEx () at ../Python/ceval.c:3251 #16 0x00005555556d493f in fast_function (nk=, na=, n=, pp_stack=0x7fffffffd3f0, func=) at ../Python/ceval.c:4818 #17 call_function (oparg=, pp_stack=0x7fffffffd3f0) at ../Python/ceval.c:4745 #18 PyEval_EvalFrameEx () at ../Python/ceval.c:3251 #19 0x00005555556d97bf in _PyEval_EvalCodeWithName () at ../Python/ceval.c:4033 #20 0x00005555556d54c9 in fast_function (nk=, na=, n=, pp_stack=0x7fffffffd600, func=) at ../Python/ceval.c:4828 #21 call_function (oparg=, pp_stack=0x7fffffffd600) at ../Python/ceval.c:4745 #22 PyEval_EvalFrameEx () at ../Python/ceval.c:3251 #23 0x00005555556d97bf in _PyEval_EvalCodeWithName () at ../Python/ceval.c:4033 #24 0x00005555556d54c9 in fast_function (nk=, na=, n=, pp_stack=0x7fffffffd810, func=) at ../Python/ceval.c:4828 #25 call_function (oparg=, pp_stack=0x7fffffffd810) at ../Python/ceval.c:4745 #26 PyEval_EvalFrameEx () at ../Python/ceval.c:3251 #27 0x00005555556da0df in _PyEval_EvalCodeWithName (qualname=0x0, name=, closure=0x0, kwdefs=0x0, defcount=1, defs=0x7ffff4de0728, kwcount=1, kws=, ---Type to continue, or q to quit--- argcount=, args=, locals=, globals=, _co=) at ../Python/ceval.c:4033 #28 PyEval_EvalCodeEx () at ../Python/ceval.c:4054 #29 0x00005555557167bf in function_call.lto_priv () at ../Objects/funcobject.c:627 #30 0x000055555575d647 in PyObject_Call () at ../Objects/abstract.c:2166 #31 0x00005555556d2180 in ext_do_call (nk=, na=, flags=, pp_stack=0x7fffffffdac8, func=) at ../Python/ceval.c:5049 #32 PyEval_EvalFrameEx () at ../Python/ceval.c:3290 #33 0x00005555556d97bf in _PyEval_EvalCodeWithName () at ../Python/ceval.c:4033 #34 0x00005555556d50a9 in fast_function (nk=, na=, n=, pp_stack=0x7fffffffdcd0, func=) at ../Python/ceval.c:4828 #35 call_function (oparg=, pp_stack=0x7fffffffdcd0) at ../Python/ceval.c:4745 #36 PyEval_EvalFrameEx () at ../Python/ceval.c:3251 #37 0x00005555556d9286 in _PyEval_EvalCodeWithName () at ../Python/ceval.c:4033 #38 0x00005555556d9f9f in PyEval_EvalCodeEx () at ../Python/ceval.c:4054 #39 PyEval_EvalCode (co=, globals=, locals=) at ../Python/ceval.c:777 #40 0x00005555557a78f2 in run_mod () at ../Python/pythonrun.c:976 #41 0x00005555557a9e1d in PyRun_FileExFlags () at ../Python/pythonrun.c:929 #42 0x00005555557aa5be in PyRun_SimpleFileExFlags () at ../Python/pythonrun.c:396 #43 0x00005555557d84d7 in run_file (p_cf=0x7fffffffdf40, filename=0x555555c0d280 L"/home/pietro/.local/bin/jupyter-notebook", fp=0x555555c6e3c0) at ../Modules/main.c:318 #44 Py_Main () at ../Modules/main.c:768 #45 0x0000555555668c01 in main () at ../Programs/python.c:65 #46 0x00007ffff6cee2b1 in __libc_start_main (main=0x555555668b20
, argc=2, argv=0x7fffffffe158, init=, fini=, rtld_fini=, stack_end=0x7fffffffe148) at ../csu/libc-start.c:291 #47 0x00005555557721ba in _start () (gdb) ```

The notebook works just fine if executed with jupyter-nbconvert --execute Untitled1.ipynb.

(Yeah, I'm pretty sure this has nothing to do with the specific pip call, but I was unable to reproduce with stupid scripts writing stuff to stdout and stderr)

This happens with jupyter version 5.2.1. If I use the system version 4.2.3-4 provided by the official Debian package, everything works fine.

takluyver commented 6 years ago

Our code is not doing anything low-level enough to directly cause a segfault, as far as I know. The issue appears to be something related to zeromq - try updating that, and if it still occurs file a bug against pyzmq or libzmq.