GeezerVison is showing github.com — gh-150436: Skip subprocess test on STATUS_DLL_INIT_FAILED (#150704) · python/cpython@e8034dd
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Lib/test/support/__init__.py +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3318,3 +3318,18 @@ def control_characters_c0() -> list[str]: | 3318 | 3318 | _ROOT_IN_POSIX = hasattr(os, 'geteuid') and os.geteuid() == 0 | 3319 | 3319 | requires_root_user = unittest.skipUnless(_ROOT_IN_POSIX, "test needs root privilege") | 3320 | 3320 | requires_non_root_user = unittest.skipIf(_ROOT_IN_POSIX, "test needs non-root account") | | 3321 | + | | 3322 | + | | 3323 | +STATUS_DLL_INIT_FAILED = 0xC0000142 | | 3324 | +def skip_on_low_desktop_heap_memory_subprocess(returncode): | | 3325 | + if sys.platform not in ('win32', 'cygwin'): | | 3326 | + return | | 3327 | + # On Windows, STATUS_DLL_INIT_FAILED is a generic error code that could | | 3328 | + # come from any of the DLLs being loaded when a new Python process is | | 3329 | + # created. In practice, it's likely a memory allocation failure in the | | 3330 | + # desktop heap memory which caused the DLL init failure, especially on | | 3331 | + # process created with CREATE_NEW_CONSOLE creation flag. See the article: | | 3332 | + # https://learn.microsoft.com/en-us/troubleshoot/windows-server/performance/desktop-heap-limitation-out-of-memory | | 3333 | + if returncode == STATUS_DLL_INIT_FAILED: | | 3334 | + raise unittest.SkipTest('gh-150436: DLL init failed, likely because ' | | 3335 | + 'of low desktop heap memory') |
Collapse file Copy file name to clipboardExpand all lines: Lib/test/test_cmd_line.py +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1036,6 +1036,7 @@ def test_python_legacy_windows_stdio(self): | 1036 | 1036 | p = subprocess.run([sys.executable, "-c", code], | 1037 | 1037 | creationflags=subprocess.CREATE_NEW_CONSOLE, | 1038 | 1038 | env=env) | | 1039 | + support.skip_on_low_desktop_heap_memory_subprocess(p.returncode) | 1039 | 1040 | self.assertEqual(p.returncode, 0) | 1040 | 1041 |
| 1041 | 1042 | # Then test that FIleIO is used when PYTHONLEGACYWINDOWSSTDIO is set. | @@ -1044,6 +1045,7 @@ def test_python_legacy_windows_stdio(self): | 1044 | 1045 | p = subprocess.run([sys.executable, "-c", code], | 1045 | 1046 | creationflags=subprocess.CREATE_NEW_CONSOLE, | 1046 | 1047 | env=env) | | 1048 | + support.skip_on_low_desktop_heap_memory_subprocess(p.returncode) | 1047 | 1049 | self.assertEqual(p.returncode, 0) | 1048 | 1050 |
| 1049 | 1051 | @unittest.skipIf("-fsanitize" in sysconfig.get_config_vars().get('PY_CFLAGS', ()), | |
Collapse file Copy file name to clipboardExpand all lines: Lib/test/test_msvcrt.py +7-2Lines changed: 7 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 4 | 4 | import unittest | 5 | 5 | from textwrap import dedent | 6 | 6 |
| | 7 | +from test import support | 7 | 8 | from test.support import os_helper, requires_resource | 8 | 9 | from test.support.os_helper import TESTFN, TESTFN_ASCII | 9 | 10 |
| @@ -67,8 +68,12 @@ def run_in_separated_process(self, code): | 67 | 68 | # Run test in a separated process to avoid stdin conflicts. | 68 | 69 | # See: gh-110147 | 69 | 70 | cmd = [sys.executable, '-c', code] | 70 | | - subprocess.run(cmd, check=True, capture_output=True, | 71 | | - creationflags=subprocess.CREATE_NEW_CONSOLE) | | 71 | + try: | | 72 | + subprocess.run(cmd, check=True, capture_output=True, | | 73 | + creationflags=subprocess.CREATE_NEW_CONSOLE) | | 74 | + except subprocess.CalledProcessError as exc: | | 75 | + support.skip_on_low_desktop_heap_memory_subprocess(exc.returncode) | | 76 | + raise | 72 | 77 |
| 73 | 78 | def test_kbhit(self): | 74 | 79 | code = dedent(''' | |
Collapse file Copy file name to clipboardExpand all lines: Lib/test/test_subprocess.py +7-3Lines changed: 7 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3765,13 +3765,17 @@ def test_startupinfo_copy(self): | 3765 | 3765 | self.assertEqual(startupinfo.wShowWindow, subprocess.SW_HIDE) | 3766 | 3766 | self.assertEqual(startupinfo.lpAttributeList, {"handle_list": []}) | 3767 | 3767 |
| | 3768 | + # CREATE_NEW_CONSOLE creates a "popup" window. | | 3769 | + @support.requires_resource('gui') | 3768 | 3770 | def test_creationflags(self): | 3769 | 3771 | # creationflags argument | 3770 | 3772 | CREATE_NEW_CONSOLE = 16 | 3771 | 3773 | sys.stderr.write(" a DOS box should flash briefly ...\n") | 3772 | | - subprocess.call(sys.executable + | 3773 | | - ' -c "import time; time.sleep(0.25)"', | 3774 | | - creationflags=CREATE_NEW_CONSOLE) | | 3774 | + rc = subprocess.call(sys.executable + | | 3775 | + ' -c "import time; time.sleep(0.25)"', | | 3776 | + creationflags=CREATE_NEW_CONSOLE) | | 3777 | + support.skip_on_low_desktop_heap_memory_subprocess(rc) | | 3778 | + self.assertEqual(rc, 0) | 3775 | 3779 |
| 3776 | 3780 | def test_invalid_args(self): | 3777 | 3781 | # invalid arguments should raise ValueError | |
|