2

I've created small app with model and view. Since the beginning PyQt5 crash each time something went wrong with
Process finished with exit code -1073740791 (0xC0000409)
Its extremely cryptic. I don't know which component failed. For some time I was able to solve this problem with debugging, but something failed and I don't know what.

How to get call stack from PyQt5? How to get more verbose crash messages?

Python 3.6.1 PyQt5 5.8.1 PyCharm

T4ng10r
  • 727
  • 2
  • 11
  • 21
  • your computer using NVIDIA card? This error relates to hardware. – Ave Mar 27 '17 at 06:21
  • I've got two graphics cards - HD Graphics 530 and NVIDIA Geforce 940MX. NVidia with driver 21.21.13.7654/376.54. – T4ng10r Mar 27 '17 at 07:05
  • Roll back your NVIDIA Driver to version **376.33**. See my answer. – Ave Mar 27 '17 at 07:06
  • After roll down - display switched from Nvidia to Intel. Currently I'm trying to make it use Nvidia again. However - run of application on supposedly Intel also fails with the same cryptic message. Nvidia instead updated to 379.09. – T4ng10r Mar 27 '17 at 07:21
  • Switch to Intel will not working. You should roll back to version 376.33 or update to latest version. This problem happens when hardware conflict. Switch from NVIDIA card to Intel not resolve your problem. – Ave Mar 27 '17 at 07:24
  • Nvidia panel shows 376.33. Windows driver for Geforce shows 21.21.13.7633. PyCharm still crashes. Intel is default used graphics card. – T4ng10r Mar 27 '17 at 07:45
  • with same issues? – Ave Mar 27 '17 at 07:46
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/139125/discussion-between-t4ng10r-and-vanloc). – T4ng10r Mar 27 '17 at 07:47

1 Answers1

5

Managed to fix it by rolling back your NVIDIA Driver to the previous version. I was on version 378.49 and switched back to 376.33 and now everything works fine. You can give that a try regardless of your graphics card.

Example with GTX 965M:

Go to Device Manager -> Display adapters -> NVIDIA GeForce GTX 965M (Right Click) -> Properties -> Driver tab -> Roll Back Driver.

Note:

There is a new version of the Nvidia driver (378.66). Comparing to the driver from guru3d - you have the driver from the original vendor and with newest fixes. :)

I have tested this version on my laptop (with GeForce GTX 960M).

It starts, works and finishes with exit code 0 on the environment console. It seems to be ok now.

Here is what Nvidia changed since the buggy (378.49) version of their driver:

(taken from http://us.download.nvidia.com/Windows/378.66/378.66-win10-win8-win7-notebook-release-notes.pdf, page 15)

Updated:

I have dealt with the same problem, and the answer is twofold:

  1. The reason it's crashing could be any number of things. It's probably a programming bug, calling a function that doesn't exist, passing a widget instead of a layout, etc. But since you're not getting the useful output you don't know where to look for the culprit.
  2. PyQT raises and catches exceptions, but doesn't pass them along. Instead, it just exits with a status of 1 to show an exception was caught.

To catch the exceptions, you need to overwrite the sys exception handler:

# Back up the reference to the exceptionhook
sys._excepthook = sys.excepthook

def my_exception_hook(exctype, value, traceback):
    # Print the error and traceback
    print(exctype, value, traceback)
    # Call the normal Exception hook after
    sys._excepthook(exctype, value, traceback)
    sys.exit(1)

# Set the exception hook to our wrapping function
sys.excepthook = my_exception_hook

Then in your execution code, wrap it in a try/catch.

try:
    sys.exit(app.exec_())
except:
    print("Exiting")
Ave
  • 4,338
  • 4
  • 40
  • 67
  • Custom exception hook helped. I see now WHERE and WHY exception appeared. Usual try/except didn't help. – T4ng10r Mar 27 '17 at 08:11