Prevent SEGV when background thread raise an exception
non-GUI thread can't open new window in PyQt. So as a band aid print the message to stderr in such case. And while at it, fix filename in error message (it was clobbered later while constructing stack trace). QubesOS/qubes-issues#1266
This commit is contained in:
parent
0b2532ae58
commit
c1552af281
@ -1985,8 +1985,15 @@ def handle_exception(exc_type, exc_value, exc_traceback):
|
|||||||
|
|
||||||
filename, line, dummy, dummy = traceback.extract_tb(exc_traceback).pop()
|
filename, line, dummy, dummy = traceback.extract_tb(exc_traceback).pop()
|
||||||
filename = os.path.basename(filename)
|
filename = os.path.basename(filename)
|
||||||
error = "%s: %s" % ( exc_type.__name__, exc_value )
|
error = "%s: %s" % (exc_type.__name__, exc_value)
|
||||||
|
message = (
|
||||||
|
"Whoops. A critical error has occured. This is most likely a bug "
|
||||||
|
"in Qubes Manager.<br><br>"
|
||||||
|
"<b><i>%s</i></b>" % error +
|
||||||
|
"<br/>at line <b>%d</b><br/>of file %s.<br/><br/>"
|
||||||
|
% (line, filename)
|
||||||
|
)
|
||||||
|
is_gui_thread = threading.currentThread().getName() == "QtMainThread"
|
||||||
strace = ""
|
strace = ""
|
||||||
stacktrace = traceback.extract_tb(exc_traceback)
|
stacktrace = traceback.extract_tb(exc_traceback)
|
||||||
while len(stacktrace) > 0:
|
while len(stacktrace) > 0:
|
||||||
@ -1997,19 +2004,16 @@ def handle_exception(exc_type, exc_value, exc_traceback):
|
|||||||
strace += "line no.: %d\n" % line
|
strace += "line no.: %d\n" % line
|
||||||
strace += "file: %s\n" % filename
|
strace += "file: %s\n" % filename
|
||||||
|
|
||||||
msg_box = QMessageBox()
|
if is_gui_thread:
|
||||||
msg_box.setDetailedText(strace)
|
msg_box = QMessageBox()
|
||||||
msg_box.setIcon(QMessageBox.Critical)
|
msg_box.setDetailedText(strace)
|
||||||
msg_box.setWindowTitle("Houston, we have a problem...")
|
msg_box.setIcon(QMessageBox.Critical)
|
||||||
msg_box.setText(
|
msg_box.setWindowTitle("Houston, we have a problem...")
|
||||||
"Whoops. A critical error has occured. This is most likely a bug "
|
msg_box.setText(message)
|
||||||
"in Qubes Manager.<br><br>"
|
|
||||||
"<b><i>%s</i></b>" % error +
|
|
||||||
"<br/>at line <b>%d</b><br/>of file %s.<br/><br/>"
|
|
||||||
% (line, filename))
|
|
||||||
|
|
||||||
msg_box.exec_()
|
|
||||||
|
|
||||||
|
msg_box.exec_()
|
||||||
|
else:
|
||||||
|
print >>sys.stderr, message
|
||||||
|
|
||||||
def sighup_handler(signum, frame):
|
def sighup_handler(signum, frame):
|
||||||
os.execl("/usr/bin/qubes-manager", "qubes-manager")
|
os.execl("/usr/bin/qubes-manager", "qubes-manager")
|
||||||
@ -2073,6 +2077,7 @@ def main():
|
|||||||
|
|
||||||
system_bus.registerObject(dbus_object_path, manager_window)
|
system_bus.registerObject(dbus_object_path, manager_window)
|
||||||
|
|
||||||
|
threading.currentThread().setName("QtMainThread")
|
||||||
trayIcon.show()
|
trayIcon.show()
|
||||||
|
|
||||||
show_manager()
|
show_manager()
|
||||||
|
Loading…
Reference in New Issue
Block a user