qml: crash reporter: handle threading.excepthook arguments
What changed, and why it matters
This commit fixes a bug in Electrum's mobile-style QML crash reporter. When an uncaught exception occurred inside a background thread, the crash reporter itself would break because it expected three pieces of information but received one bundled object. As a result, users would see a confusing secondary error instead of the real crash details. The fix unpacks the bundled object correctly and also logs the actual exception message. It is a reliability/usability fix, not a security vulnerability.
Treat as a normal bug-fix commit. No security response required. Ensure the QML crash reporter is exercised with a failing background thread to confirm the real exception is now reported.
Security signals we found
Crash reporter failure could hide or obscure real runtime errors in background threads
No input validation, privilege boundary, or cryptographic issue present
Fix improves diagnostic fidelity but does not close an attack vector
Evidence from the diff
Exception_Hook.handler in electrum/gui/qml/qeapp.py is registered to both sys.excepthook and threading.excepthook. The signatures differ: sys.excepthook passes (exc_type, exc_value, exc_traceback), while threading.excepthook passes a single threading.ExceptHookArgs object. The original handler unconditionally treated the argument tuple as exc_info, so for thread exceptions BaseCrashReporter.get_traceback_groupid_hash() received an ExceptHookArgs as exc_type and raised a TypeError. The patch detects the single-argument case, extracts the real exc_type/value/traceback, and logs the exception value. This prevents the crash reporter from masking the original thread exception.
Changed components
electrum/gui/qml/qeapp.pyException_Hook.handlerQML GUI crash reporterInspect captured patch +4 / −1
### electrum/gui/qml/qeapp.py
@@ -654,7 +654,10 @@ def maybe_setup(cls, *, wallet: 'Abstract_Wallet' = None, slot=None) -> None:
cls._INSTANCE.wallet_types_seen.add(wallet.wallet_type)
def handler(self, *exc_info):
- self.logger.error('exception caught by crash reporter', exc_info=exc_info)
+ if len(exc_info) == 1: # threading.excepthook passes a single ExceptHookArgs
+ args = exc_info[0]
+ exc_info = (args.exc_type, args.exc_value, args.exc_traceback)
+ self.logger.error(f'exception caught by crash reporter {repr(exc_info[1])}', exc_info=exc_info)
groupid_hash = BaseCrashReporter.get_traceback_groupid_hash(*exc_info)
if groupid_hash in self.exception_ids_seen:
return # to avoid annoying the user, only show crash reporter once per exception groupidWhy this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.