a-shell icon indicating copy to clipboard operation
a-shell copied to clipboard

Jupyter Server Fails with Segmentation Fault on Build 486

Open IcEarthlight opened this issue 4 months ago • 1 comments

On the latest a-Shell build 486, running jupyter server-related commands frequently results in a segmentation fault. While some commands may start the server successfully, it soon crashes (with the same segmentation fault errors), rendering it unusable. This issue was not present in previous builds (e.g., build 484 and earlier) which used Python 3.11.

Commands that always fail with a segmentation fault:

$ jupyter-server
$ jupyter server

These commands may sometimes run successfully, but often fail with a similar segmentation fault:

$ jupyter-notebook
$ jupyter notebook --no-browser
$ jupyter notebook --ip=0.0.0.0 --ServerApp.token=""

The following commands can successfully start the server, but it eventually crashes with a similar segmentation fault, making it unusable:

$ python -m jupyter_server
$ python -m jupyter_notebook

The traceback for the failures is consistent, pointing to a "Fatal Python error" followed by a segmentation fault.

Fatal Python error: pyinit_core_reconfigure: failed to read thread state
Python runtime state: initialized

Thread 0x000000016dc4f000 (most recent call first):
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1760 in create_module
  File "<frozen importlib._bootstrap>", line 813 in module_from_spec
  File "<frozen importlib._bootstrap>", line 921 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
segmentation fault

This issue seems to be specific to the recent Python 3.13 update in a-Shell. I previously used python -m jupyter_server --ip="0.0.0.0" on builds prior to 484 (with Python 3.11), and it worked without any issues.

original error messages for referencing:
[Documents]$ jupyter-server
segmentation fault
[Documents]$ jupyter server
Fatal Python error: pyinit_core_reconfigure: failed to read thread state
Python runtime state: initialized

Thread 0x000000016c00f000 (most recent call first):
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1760 in create_module
  File "<frozen importlib._bootstrap>", line 813 in module_from_spec
  File "<frozen importlib._bootstrap>", line 921 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File segmentation fault
[Documents]$ jupyter-notebook
(Output nothing when failed)
[Documents]$ jupyter notebook --no-browser
Fatal Python error: pyinit_core_reconfigure: failed to read thread state
Python runtime state: initialized

Thread 0x000000016dc4f000 (most recent call first):
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1760 in create_module
  File "<frozen importlib._bootstrap>", line 813 in module_from_spec
  File "<frozen importlib._bootstrap>", line 921 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
segmentation fault
[Documents]$ jupyter notebook --ip=0.0.0.0 --ServerApp.token=""
Fatal Python error: pyinit_core_reconfigure: failed to read thread state
Python runtime state: initialized

Thread 0x000000016afff000 (most recent call first):
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1760 in create_module
  File "<frozen importlib._bootstrap>", line 813 in module_from_spec
  File "<frozen importlib._bootstrap>", line 921 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File ???, line 1 in segmentation fault
[Documents]$ python -m jupyter_server --ip=0.0.0.0 --ServerApp.token=""
[W 2025-09-11 01:35:42.908 ServerApp] ServerApp.token config is deprecated in 2.0. Use IdentityProvider.token.
[I 2025-09-11 01:35:42.949 ServerApp] Package jupyter_lsp took 0.0242s to import
[I 2025-09-11 01:35:42.960 ServerApp] Package jupyter_server_terminals took 0.0107s to import
[I 2025-09-11 01:35:43.063 ServerApp] Package jupyterlab took 0.1030s to import
[I 2025-09-11 01:35:43.202 ServerApp] Package nbclassic took 0.0045s to import
[W 2025-09-11 01:35:43.204 ServerApp] A `_jupyter_server_extension_points` function was not found in nbclassic. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2025-09-11 01:35:43.204 ServerApp] Package notebook took 0.0000s to import
[I 2025-09-11 01:35:43.207 ServerApp] Package notebook_shim took 0.0000s to import
[I 2025-09-11 01:35:43.208 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2025-09-11 01:35:43.212 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2025-09-11 01:35:43.215 ServerApp] jupyterlab | extension was successfully linked.
[I 2025-09-11 01:35:43.218 ServerApp] nbclassic | extension was successfully linked.
[I 2025-09-11 01:35:43.221 ServerApp] notebook | extension was successfully linked.
[I 2025-09-11 01:35:43.558 ServerApp] Package jupyter_nbextensions_configurator took 0.0011s to import
[W 2025-09-11 01:35:43.558 ServerApp] A `_jupyter_server_extension_points` function was not found in jupyter_nbextensions_configurator. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2025-09-11 01:35:43.558 ServerApp] jupyter_nbextensions_configurator | extension was found and enabled by notebook_shim. Consider moving the extension to Jupyter Server's extension paths.
[I 2025-09-11 01:35:43.558 ServerApp] jupyter_nbextensions_configurator | extension was successfully linked.
[I 2025-09-11 01:35:43.559 ServerApp] notebook_shim | extension was successfully linked.
[I 2025-09-11 01:35:43.580 ServerApp] notebook_shim | extension was successfully loaded.
[I 2025-09-11 01:35:43.583 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2025-09-11 01:35:43.583 ServerApp] [jupyter_nbextensions_configurator] enabled 0.6.4
[I 2025-09-11 01:35:43.583 ServerApp] jupyter_nbextensions_configurator | extension was successfully loaded.
[I 2025-09-11 01:35:43.584 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2025-09-11 01:35:43.587 LabApp] JupyterLab extension loaded from /var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Library/lib/python3.13/site-packages/jupyterlab
[I 2025-09-11 01:35:43.587 LabApp] JupyterLab application directory is /private/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Library/share/jupyter/lab
[I 2025-09-11 01:35:43.587 LabApp] Extension Manager is 'pypi'.
[I 2025-09-11 01:35:43.626 ServerApp] jupyterlab | extension was successfully loaded.

  _   _          _      _
 | | | |_ __  __| |__ _| |_ ___
 | |_| | '_ \/ _` / _` |  _/ -_)
  \___/| .__/\__,_\__,_|\__\___|
       |_|

Read the migration plan to Notebook 7 to learn about the new features and the actions to take if you are using extensions.

https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html

Please note that updating to Notebook 7 might break some of your extensions.

[I 2025-09-11 01:35:43.633 ServerApp] nbclassic | extension was successfully loaded.
[I 2025-09-11 01:35:43.636 ServerApp] notebook | extension was successfully loaded.
[I 2025-09-11 01:35:43.636 ServerApp] Serving notebooks from local directory: /private/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Documents
[I 2025-09-11 01:35:43.636 ServerApp] Jupyter Server 2.10.0 is running at:
[I 2025-09-11 01:35:43.636 ServerApp] http://iPhone-3:8888/?token=...
[I 2025-09-11 01:35:43.636 ServerApp]     http://127.0.0.1:8888/?token=...
[I 2025-09-11 01:35:43.637 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 2025-09-11 01:35:43.681 ServerApp] Skipped non-installed server(s): basedpyright, bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyrefly, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
[I 2025-09-11 01:35:58.487 ServerApp] Creating new notebook in 
[W 2025-09-11 01:35:58.487 ServerApp] 404 POST /api/contents?1757518558323 (192.168.1.4): No such directory: private/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Documents
[W 2025-09-11 01:35:58.487 ServerApp] wrote error: 'No such directory: private/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Documents'
    Traceback (most recent call last):
      File "/private/var/containers/Bundle/Application/F92F6A8C-2348-4722-A108-84365876B32B/a-Shell.app/Library/lib/python3.13/site-packages/tornado/web.py", line 1848, in _execute
        result = await result
                 ^^^^^^^^^^^^
      File "/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Library/lib/python3.13/site-packages/jupyter_server/services/contents/handlers.py", line 240, in post
        await self._new_untitled(path, type=type, ext=ext)
      File "/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Library/lib/python3.13/site-packages/jupyter_server/services/contents/handlers.py", line 187, in _new_untitled
        model = await ensure_async(
                ^^^^^^^^^^^^^^^^^^^
            self.contents_manager.new_untitled(path=path, type=type, ext=ext)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Library/lib/python3.13/site-packages/jupyter_core/utils/__init__.py", line 197, in ensure_async
        result = await obj
                 ^^^^^^^^^
      File "/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Library/lib/python3.13/site-packages/jupyter_server/services/contents/manager.py", line 951, in new_untitled
        raise HTTPError(404, "No such directory: %s" % path)
    tornado.web.HTTPError: HTTP 404: Not Found (No such directory: private/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Documents)
[W 2025-09-11 01:35:58.499 ServerApp] 404 POST /api/contents?1757518558323 ([email protected]) 12.77ms referer=http://192.168.1.5:8888/tree
[I 2025-09-11 01:36:05.066 ServerApp] Kernel started: b9dc9d91-b9c1-433b-be6a-06da5a52f59e
segmentation fault
[I 2025-09-11 01:36:08.048 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), new random ports
Fatal Python error: pyinit_core_reconfigure: failed to read thread state
Python runtime state: initialized

Thread 0x000000016bc53000 (most recent call first):
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1760 in create_module
  File "<frozen importlib._bootstrap>", line 813 in module_from_spec
  File "<frozen importlib._bootstrap>", line 921 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File segmentation fault
[I 2025-09-11 01:36:11.066 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (2/5), new random ports
[I 2025-09-11 01:36:14.085 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (3/5), new random ports
[I 2025-09-11 01:36:17.103 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (4/5), new random ports
[I 2025-09-11 01:36:20.121 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (5/5), new random ports
[W 2025-09-11 01:36:23.139 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2025-09-11 01:36:23.140 ServerApp] Kernel b9dc9d91-b9c1-433b-be6a-06da5a52f59e died, removing from map.
[W 2025-09-11 01:36:25.621 ServerApp] 404 GET /api/kernels/b9dc9d91-b9c1-433b-be6a-06da5a52f59e?1757518585147 (192.168.1.4): Kernel does not exist: b9dc9d91-b9c1-433b-be6a-06da5a52f59e
[W 2025-09-11 01:36:25.621 ServerApp] wrote error: 'Kernel does not exist: b9dc9d91-b9c1-433b-be6a-06da5a52f59e'
    Traceback (most recent call last):
      File "/private/var/containers/Bundle/Application/F92F6A8C-2348-4722-A108-84365876B32B/a-Shell.app/Library/lib/python3.13/site-packages/tornado/web.py", line 1848, in _execute
        result = await result
                 ^^^^^^^^^^^^
      File "/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Library/lib/python3.13/site-packages/jupyter_server/services/kernels/handlers.py", line 75, in get
        model = await ensure_async(km.kernel_model(kernel_id))
                                   ~~~~~~~~~~~~~~~^^^^^^^^^^^
      File "/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Library/lib/python3.13/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 505, in kernel_model
        self._check_kernel_id(kernel_id)
        ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
      File "/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Library/lib/python3.13/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 536, in _check_kernel_id
        raise web.HTTPError(404, "Kernel does not exist: %s" % kernel_id)
    tornado.web.HTTPError: HTTP 404: Not Found (Kernel does not exist: b9dc9d91-b9c1-433b-be6a-06da5a52f59e)
[W 2025-09-11 01:36:25.625 ServerApp] 404 GET /api/kernels/b9dc9d91-b9c1-433b-be6a-06da5a52f59e?1757518585147 ([email protected]) 3.98ms referer=http://192.168.1.5:8888/tree
[W 2025-09-11 01:36:25.665 ServerApp] 404 GET /api/kernels/b9dc9d91-b9c1-433b-be6a-06da5a52f59e/channels?session_id=dc110b85-5baf-411c-bb15-a47f8e01e413 (192.168.1.4): Kernel does not exist: b9dc9d91-b9c1-433b-be6a-06da5a52f59e
[W 2025-09-11 01:36:25.680 ServerApp] 404 GET /api/kernels/b9dc9d91-b9c1-433b-be6a-06da5a52f59e/channels?session_id=dc110b85-5baf-411c-bb15-a47f8e01e413 ([email protected]) 14.75ms referer=None
[W 2025-09-11 01:36:25.769 ServerApp] 404 GET /api/kernels/b9dc9d91-b9c1-433b-be6a-06da5a52f59e?1757518585693 (192.168.1.4): Kernel does not exist: b9dc9d91-b9c1-433b-be6a-06da5a52f59e
[W 2025-09-11 01:36:25.769 ServerApp] wrote error: 'Kernel does not exist: b9dc9d91-b9c1-433b-be6a-06da5a52f59e'
    Traceback (most recent call last):
      File "/private/var/containers/Bundle/Application/F92F6A8C-2348-4722-A108-84365876B32B/a-Shell.app/Library/lib/python3.13/site-packages/tornado/web.py", line 1848, in _execute
        result = await result
                 ^^^^^^^^^^^^
      File "/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Library/lib/python3.13/site-packages/jupyter_server/services/kernels/handlers.py", line 75, in get
        model = await ensure_async(km.kernel_model(kernel_id))
                                   ~~~~~~~~~~~~~~~^^^^^^^^^^^
      File "/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Library/lib/python3.13/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 505, in kernel_model
        self._check_kernel_id(kernel_id)
        ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
      File "/var/mobile/Containers/Data/Application/7C43D3DA-E207-41AF-AAEA-C8F976E57104/Library/lib/python3.13/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 536, in _check_kernel_id
        raise web.HTTPError(404, "Kernel does not exist: %s" % kernel_id)
    tornado.web.HTTPError: HTTP 404: Not Found (Kernel does not exist: b9dc9d91-b9c1-433b-be6a-06da5a52f59e)
[W 2025-09-11 01:36:25.770 ServerApp] 404 GET /api/kernels/b9dc9d91-b9c1-433b-be6a-06da5a52f59e?1757518585693 ([email protected]) 1.79ms referer=http://192.168.1.5:8888/tree

IcEarthlight avatar Sep 10 '25 15:09 IcEarthlight

There were quite a few issues in there (the new build system for pyzmq did not link it with -framework Python, and as a result PyImport_ImportModule was the wrong function, ipykernel and some others were still using if sys.platform == 'darwin' instead of the new if sys.platform == 'ios' in some places...) but it should work with build 487 (I've opened a notebook, ran its cells and shut down jupyter server without issues).

holzschu avatar Sep 15 '25 20:09 holzschu