Skip to content

[Bug] QGIS crashes instantly on macOS (arm64) in v5.0.3 – QDialog opened from background thread during dependency install #48

@zicherino

Description

@zicherino

[Bug] QGIS crashes instantly on macOS (arm64) in v5.0.3 – QDialog opened from background thread during dependency install

Description

This is a follow-up to #47 (Python interpreter mismatch on macOS arm64), which was fixed in v5.0.3.

After updating to v5.0.3, the interpreter fix works — QGIS now finds the correct Python. However, a new crash has been introduced: QGIS crashes immediately (SIGABRT) when Dzetsaka attempts to install the remaining missing packages. The crash occurs because a QDialog is being opened from within a background QgsTask thread, which violates Qt's rule that all GUI operations must happen on the main thread.

In v5.0.2, this code path was never reached (the wrong interpreter was used, so installation silently failed). Now that the interpreter is correctly detected and installation actually proceeds, the threading bug is exposed.

This is a hard crash with no recovery — QGIS terminates instantly.

Environment

  • QGIS Version: 3.44.7
  • Dzetsaka Version: 5.0.3 (regression introduced in this version)
  • OS: macOS 26.3 (Apple Silicon / ARM64, MacBook Pro)
  • Python: 3.12

Steps to Reproduce

  1. Install Dzetsaka plugin in QGIS on macOS (Apple Silicon)
  2. Open the Dzetsaka panel
  3. Dzetsaka detects missing packages and attempts to auto-install them
  4. QGIS crashes instantly

Missing packages that triggered the crash:

  • lightgbm
  • optuna
  • shap
  • seaborn

Full bundle Dzetsaka attempted to install:
scikit-learn, xgboost, catboost, optuna, shap, seaborn, imbalanced-learn

Expected Behavior

Missing packages are installed silently in the background, or the user is prompted in a thread-safe way (e.g. via a signal/slot mechanism to the main thread).

Actual Behavior

QGIS crashes immediately with EXC_CRASH (SIGABRT).

Crash Analysis

The macOS crash report clearly shows the cause. Thread 18 (a pooled Qt thread running QgsTask) calls QDialog::exec() directly, which is forbidden outside the main thread:

34  _core.so                 sipQgsTask::run()
...
27  QtWidgets.abi3.so        meth_QDialog_exec(...)   ← GUI call from background thread
26  libQt5Widgets.5.15.dylib QDialog::exec()
...
11  AppKit                   -[NSWindow _initContent:styleMask:backing:defer:contentView:]
10  CoreFoundation           -[NSException raise]     ← macOS throws exception
 2  libsystem_c.dylib        abort()                  ← SIGABRT → QGIS terminates

Root cause: The dependency installation routine runs inside a QgsTask and opens a QDialog from that background thread. On macOS (especially Apple Silicon), AppKit enforces strict main-thread-only UI access and throws an NSException, which propagates as a C++ exception and causes abort().

This does not appear to affect Windows or Linux, where the restriction is not enforced at the OS level.

Workaround

Install all required packages manually into QGIS's Python environment before launching QGIS:

/Applications/QGIS.app/Contents/MacOS/bin/python3 -m pip install \
  lightgbm optuna shap seaborn \
  scikit-learn xgboost catboost \
  imbalanced-learn --upgrade

Doesn't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions