Skip to content

Windows fatal exception: access violation #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
czhhua28 opened this issue Mar 11, 2020 · 5 comments
Open

Windows fatal exception: access violation #204

czhhua28 opened this issue Mar 11, 2020 · 5 comments
Labels
3rd-party issue related to specific windows stuffs or python packages

Comments

@czhhua28
Copy link

image
This is my script.

image
This is the result.

I just wonder how that fatal exception occurs and how we can fix it.

@michel117
Copy link

michel117 commented Mar 17, 2020

I have a pretty similar problem with using pytest. I think it has nothing to do with pywinauto.

================================================== warnings summary ===================================================
test/*****.py::test_open_dialog
  D:\U****\Python38\site-packages\win32\lib\pywintypes.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import imp, sys, os

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=============================================== short test summary info ===============================================
FAILED test/test_****.py::test_open_dialog - NameError: name '****' is not defined
============================================ 1 failed, 1 warning in 0.34s =============================================
Windows fatal exception: code 0x80010108

Thread 0x00002418 (most recent call first):
  File "D:\Users\*****\AppData(Roaming)\Python\Python38\site-packages\comtypes\__init__.py", line 185 in shutdown
Windows fatal exception: code 0x80010108

Thread 0x00002418 (most recent call first):
  File "D:\Users\*****\AppData(Roaming)\Python\Python38\site-packages\comtypes\__init__.py", line 185 in shutdown

pytest version 5.4.0 and 5.4.1
comtypes Version: 1.1.7

@RoyLarson
Copy link

I have a similar issue with a different COM library where pytest ends up printing out a

Windows fatal exception: access violation

The interesting thing about my issue is that it only happens when I run

C:\%userprofile%\projects\pycygnet\py.test

Current thread 0x0000cfec (most recent call first):
  File "C:\%userprofile%\anaconda3\envs\pycygnet_dev\lib\site-packages\comtypes\__init__.py", line 1354 in CoGetClassObject
  File "C:\%userprofile%\anaconda3\envs\pycygnet_dev\lib\site-packages\comtypes\client\__init__.py", line 203 in GetClassObject
  File "C:\%userprofile%\Projects\PyCygNet\src\pycygnet\cx_fac\__init__", line 6 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
...
  File "C:\%userprofile%\anaconda3\envs\pycygnet_dev\Scripts\py.test-script.py", line 10 in <module>
Windows fatal exception: access violation

if I specify the test a little more I get the normal output from pytest

C:\%userprofile%\projects\pycygnet\py.test tests\test_cx_fac

============================================================================================== test session starts ============================================================================================== platform win32 -- Python 3.7.4, pytest-5.2.1, py-1.8.1, pluggy-0.13.1
rootdir: C:\%userprofile%\Projects\PyCygNet
collected 19 items

tests\test_fac\test_cx_fac.py ...........sss....s

@iloeng
Copy link

iloeng commented Jun 1, 2020

I have a similar issue. execute result are as follows:

(auto-client) D:\Projects\Python\Client_UI>python test_client.py
..                                                                                                               [100%]
2 passed in 3.21s
Windows fatal exception: code 0x80010108

Thread 0x00003460 (most recent call first):
  File "C:\Anaconda3\envs\auto-client\lib\site-packages\comtypes\__init__.py", line 185 in shutdown
Windows fatal exception: code 0x80010108

Thread 0x00003460 (most recent call first):
  File "C:\Anaconda3\envs\auto-client\lib\site-packages\comtypes\__init__.py", line 185 in shutdown

(auto-client) D:\Projects\Python\Client_UI>

my test code :

import Client
import pytest
import faulthandler
faulthandler.disable()


class TestClient(object):

    def setup(self):
        print("======= [ Start ] =======")
        self.meetingpage = Client.MeetingsPage()

    def teardown(self):
        print("======= [ Stop ] =======")

    def test_a(self):
        self.meetingpage = Client.MeetingsPage()
        self.meetingpage.click_meetings_icon()
        meeting_id = '2126549589'
        meeting_cell = self.meetingpage.meeting_item(meeting_id)

    def test_b(self):
        print("------->test_b")


if __name__ == '__main__':
    pytest.main(["-q", "test_client.py"])

comtypes : 1.1.7
pytest: 5.4.2

@bored002
Copy link

I'm Facing the same issue :
pytest : 5.2.2
comtype: 1.1.10

@moi15moi
Copy link
Contributor

moi15moi commented Apr 17, 2025

I'm not able to reproduce the issue with the latest comtypes version.
comtypes: 1.4.10
pywinauto: 0.6.9
pytest: 8.3.5

I also tested with comtypes 1.1.11 and the issue didn't occur.

I tried with the script provided by the creator of this issue:

import pytest
from pywinauto.application import Application

def test_case():
    assert True

Is seems that everyone in this issue is using the version 1.1.7 or 1.1.10. Both of them are pretty old. I wasn't able to try them because they aren't compatible with Python 3.12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd-party issue related to specific windows stuffs or python packages
Projects
None yet
Development

No branches or pull requests

7 participants