Repository navigation
DataLab crashes (access violation) when a computation requested remotely fails #404
Description
Describe the bug
When a computation requested through remote control fails, DataLab crashes with a native access violation (0xC0000005) instead of reporting the error. This happens with XML-RPC (calc) and with the Web API (POST /api/v1/calc). The client gets ConnectionRefusedError (XML-RPC) or ConnectionResetError (Web API).
The exception raised by the computation is caught by the qt_try_except decorator of BaseProcessor.run_feature, which calls qt_handle_error_message: the crash occurs in its QMessageBox.critical(...) call.
Windows fatal exception: access violation
Current thread 0x0001c72c (most recent call first):
File "C:\Dev\Projets\SigimaX\sigimax\utils\qthelpers.py", line 359 in qt_handle_error_message
File "C:\Dev\Projets\DataLab\datalab\utils\qthelpers.py", line 128 in method_wrapper
File "C:\Dev\Projets\DataLab\datalab\gui\main.py", line 1879 in calc
File "C:\Dev\Projets\DataLab\datalab\gui\main.py", line 131 in method_wrapper
...
To Reproduce
"""DataLab crashes when a computation requested remotely fails"""
import os
import numpy as np
if __name__ == "__main__":
# Imported here: the DataLab process must not import the test helpers (pytest)
from datalab.env import execenv
from datalab.tests import datalab_in_background_context
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
execenv.unattended = True
with datalab_in_background_context() as proxy:
proxy.add_signal("One point", np.array([0.0]), np.array([1.0]))
proxy.select_objects([1], "signal")
# The derivative of a one-point signal raises IndexError in Sigima
proxy.calc("derivative")Result:
- the script fails with
ConnectionRefusedError: [WinError 10061]; - the DataLab process exits with code 3221225477 (
0xC0000005); ~/.DataLab_v1/.DataLab_faulthandler.logcontains the traceback above.
The same crash occurs with the Web API, started with DATALAB_WEBAPI_ENABLED=1, when calling POST /api/v1/calc with {"name": "derivative"} on the same selection (checked on the branch of #402, which does not change this code path; the XML-RPC case was checked on both branches).
Expected behavior
DataLab keeps running, and the error is reported to the remote client: as an xmlrpc.client.Fault with XML-RPC, as an HTTP error with the Web API. A remote request should not open a modal message box.
Installation information
- Python package (development checkout),
developbranch at c800d5e - DataLab 1.3.0, Sigima 1.3.0, SigimaX 1.1.0, PlotPy 2.11.1, guidata 3.16.0, PyQt5 5.15.11 (Qt 5.15.2), FastAPI 0.136.0, uvicorn 0.45.0, Python 3.11.6, NumPy 2.4.4, Windows 10.0.26200
Additional context
- Observed with
QT_QPA_PLATFORM=offscreenin unattended mode, i.e. a background DataLab as used by tests and automation. Not checked with a visible window, where the modal message box would at least block the remote call until it is closed, without reporting the error to the client. - The test suite cannot catch this: when the DataLab process imports
pytest(e.g. throughdatalab.tests),is_running_tests()makesqt_try_exceptre-raise the exception instead of showing the message box. With Fix remote file loading intermittently ignored at DataLab startup #402, the error then reaches the client asxmlrpc.client.Fault: <class 'IndexError'>:index 0 is out of bounds for axis 0 with size 0. - Found while investigating Remote
load_from_files/load_from_directoryintermittently ignored #398 (see Fix remote file loading intermittently ignored at DataLab startup #402), which does not change this behavior: the crash also occurs on its branch.
Activity