Skip to content

Windows CI new failures: "Security must be initialized before any interfaces are marshalled" #96684

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

Closed
sobolevn opened this issue Sep 8, 2022 · 3 comments
Assignees
Labels
OS-windows type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Sep 8, 2022

It started to happen after de33df2
CC @zooba

Link: https://dev.azure.com/Python/cpython/_build/results?buildId=111384&view=logs&j=0fcf9c9b-89fc-526f-8708-363e467e119e&t=fa5ef4ee-3911-591e-4444-19482ab189b7&l=244

======================================================================
ERROR: test_wmi_query_os_version (test.test_wmi.WmiTests.test_wmi_query_os_version)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\1\b\layout-appx-win32\Lib\test\test_wmi.py", line 16, in test_wmi_query_os_version
    r = _wmi.exec_query("SELECT Version FROM Win32_OperatingSystem").split("\0")
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError -2147417831] Security must be initialized before any interfaces are marshalled or unmarshalled. It cannot be changed once initialized

======================================================================
ERROR: test_wmi_query_repeated (test.test_wmi.WmiTests.test_wmi_query_repeated)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\1\b\layout-appx-win32\Lib\test\test_wmi.py", line 28, in test_wmi_query_repeated
    self.test_wmi_query_os_version()
  File "D:\a\1\b\layout-appx-win32\Lib\test\test_wmi.py", line 16, in test_wmi_query_os_version
    r = _wmi.exec_query("SELECT Version FROM Win32_OperatingSystem").split("\0")
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError -2147417831] Security must be initialized before any interfaces are marshalled or unmarshalled. It cannot be changed once initialized

======================================================================
FAIL: test_wmi_query_repeated_error (test.test_wmi.WmiTests.test_wmi_query_repeated_error)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\1\b\layout-appx-win32\Lib\test\test_wmi.py", line 42, in test_wmi_query_repeated_error
    self.test_wmi_query_error()
  File "D:\a\1\b\layout-appx-win32\Lib\test\test_wmi.py", line 38, in test_wmi_query_error
    self.fail("Expected OSError")
AssertionError: Expected OSError

----------------------------------------------------------------------
Ran 4 tests in 0.047s

Traceback (most recent call last):
FAILED (failures=1, errors=2)
test test_wmi failed
1 test failed again:
    test_wmi
@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error OS-windows labels Sep 8, 2022
@eryksun
Copy link
Contributor

eryksun commented Sep 8, 2022

Maybe _wmi could ignore RPC_E_TOO_LATE when calling CoInitializeSecurity(). The process-wide security for COM may have already been set by the application or another extension module. However security was initialized, hopefully it allows connecting to the WMI server.

@zooba
Copy link
Member

zooba commented Sep 8, 2022

Maybe _wmi could ignore RPC_E_TOO_LATE when calling CoInitializeSecurity().

That's what I was thinking. I saw this error pop up a few times while testing, but couldn't reproduce it consistently (apart from when I broke the CoUninitialize call...).

My worry with ignoring this error code is that we might just fail at the next step anyway. In "real life" this is fine, because platform has fallbacks, but if it's going to break tests then it'll be harder to keep things reliable.

@zooba
Copy link
Member

zooba commented Sep 8, 2022

That seems to have satisfied the Pipelines build, but we can reopen if we discover that it hasn't solved the issue completely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-windows type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants