Nuitka: Access violation/segmentation fault when disconnecting PySide6 signals
I am aware that you do not recommend bundling pytest, but I explained why I am doing it, and I wondered if “Windows fatal exception: access violation” sounds serious enough to take the off-chance of finding and fixing a more general issue.
This is my current environment - the same thing happens on Python 3.10.10:
C:\code\project>python -m nuitka --version
1.5rc12
Commercial: None
Python: 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)]
Flavor: Unknown
Executable: C:\Users\bers\.pyenv-win-venv\envs\project_3.11\Scripts\python.exe
OS: Windows
Arch: x86_64
WindowsRelease: 10
Version C compiler: C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.34.31933\bin\HostX64\x64\cl.exe (cl 14.3).
C:\Code\bug>pip freeze
attrs==22.2.0
colorama==0.4.6
iniconfig==2.0.0
Nuitka @ git+https://github.com/Nuitka/Nuitka@ab59f9bd0c25a39aaab870b6570d477a46731130
ordered-set==4.1.0
packaging==23.0
pluggy==1.0.0
PySide6-Essentials==6.4.2
pytest==7.2.1
pytest-qt==4.2.0
shiboken6==6.4.2
zstandard==0.20.0
Installed Nuitka from pip and GitHub.
bug.py
import pytest
pytest.main([__file__ + "/.."], ["pytestqt.plugin"])
test_bug.py (could potentially be minimized further)
def test_bug(qtbot):
qtbot.waitUntil(lambda: False)
bug.bat
@echo off
python -m pip install PySide6-Essentials pytest-qt git+https://github.com/Nuitka/Nuitka
python -m nuitka ^
--standalone ^
--enable-plugin=pyside6 ^
--include-data-file=test_bug.py=./ ^
--include-module=PySide6.QtTest ^
--include-module=pytest ^
--include-module=_pytest ^
--include-module=pytestqt ^
bug.py
bug.dist\bug.exe
Output:
[...]
Nuitka:INFO: Successfully created 'bug.dist\bug.exe'.
=================================================================================== test session starts ===================================================================================
platform win32 -- Python 3.11.2, pytest-7.2.1, pluggy-1.0.0
PySide6 6.4.2 -- Qt runtime 6.4.2 -- Qt compiled 6.4.2
rootdir: C:\Code\bug
collected 1 item
BUG~1.DIS\test_bug.py Windows fatal exception: access violation
Current thread 0x00005fc4 (most recent call first):
File "C:\Code\bug\BUG~1.DIS\pytestqt\wait_signal.py", line 34 in wait
File "C:\Code\bug\BUG~1.DIS\pytestqt\qtbot.py", line 440 in wait
File "C:\Code\bug\BUG~1.DIS\pytestqt\qtbot.py", line 474 in waitUntil
File "C:\Code\bug\BUG~1.DIS\test_bug.py", line 2 in test_bug
File "C:\Code\bug\BUG~1.DIS\_pytest\python.py", line 195 in pytest_pyfunc_call
File "C:\Code\bug\BUG~1.DIS\pluggy\_callers.py", line 9 in _multicall
File "C:\Code\bug\BUG~1.DIS\pluggy\_manager.py", line 77 in _hookexec
File "C:\Code\bug\BUG~1.DIS\pluggy\_hooks.py", line 244 in __call__
File "C:\Code\bug\BUG~1.DIS\_pytest\python.py", line 1789 in runtest
File "C:\Code\bug\BUG~1.DIS\_pytest\runner.py", line 167 in pytest_runtest_call
File "C:\Code\bug\BUG~1.DIS\pluggy\_callers.py", line 9 in _multicall
File "C:\Code\bug\BUG~1.DIS\pluggy\_manager.py", line 77 in _hookexec
File "C:\Code\bug\BUG~1.DIS\pluggy\_hooks.py", line 244 in __call__
File "C:\Code\bug\BUG~1.DIS\_pytest\runner.py", line 260 in <lambda>
File "C:\Code\bug\BUG~1.DIS\_pytest\runner.py", line 339 in from_call
File "C:\Code\bug\BUG~1.DIS\_pytest\runner.py", line 259 in call_runtest_hook
File "C:\Code\bug\BUG~1.DIS\_pytest\runner.py", line 220 in call_and_report
File "C:\Code\bug\BUG~1.DIS\_pytest\runner.py", line 131 in runtestprotocol
File "C:\Code\bug\BUG~1.DIS\_pytest\runner.py", line 112 in pytest_runtest_protocol
File "C:\Code\bug\BUG~1.DIS\pluggy\_callers.py", line 9 in _multicall
File "C:\Code\bug\BUG~1.DIS\pluggy\_manager.py", line 77 in _hookexec
File "C:\Code\bug\BUG~1.DIS\pluggy\_hooks.py", line 244 in __call__
File "C:\Code\bug\BUG~1.DIS\_pytest\main.py", line 349 in pytest_runtestloop
File "C:\Code\bug\BUG~1.DIS\pluggy\_callers.py", line 9 in _multicall
File "C:\Code\bug\BUG~1.DIS\pluggy\_manager.py", line 77 in _hookexec
File "C:\Code\bug\BUG~1.DIS\pluggy\_hooks.py", line 244 in __call__
File "C:\Code\bug\BUG~1.DIS\_pytest\main.py", line 324 in _main
File "C:\Code\bug\BUG~1.DIS\_pytest\main.py", line 270 in wrap_session
File "C:\Code\bug\BUG~1.DIS\_pytest\main.py", line 317 in pytest_cmdline_main
File "C:\Code\bug\BUG~1.DIS\pluggy\_callers.py", line 9 in _multicall
File "C:\Code\bug\BUG~1.DIS\pluggy\_manager.py", line 77 in _hookexec
File "C:\Code\bug\BUG~1.DIS\pluggy\_hooks.py", line 244 in __call__
File "C:\Code\bug\BUG~1.DIS\_pytest\config\__init__.py", line 167 in main
File "C:\Code\bug\BUG~1.DIS\bug.py", line 1 in <module>
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 50 (18 by maintainers)
I think the workaround for a corruption bug of PySide6 might actually help. Please checkout develop or 1.5.7
Here’s another funny variant that shows that you can reuse the same
Blockerinstance, and don’t need to connect the same kind of signal twice:Minimized further - this is fully independent of
pytestnow:bug2.py:bug2.bat:Output:
(And then the process ends without
Done.)Right, sorry for that. Version output on 3.11:
qtbotis whatpytestcalls a fixture, and it is provided bypytest-qtthrough thepytestqt.qtbot.QtBotclass. It is instantiated bypytestwhich passes somerequest, and which I believe is the reason that(https://pytest-qt.readthedocs.io/en/latest/reference.html)
That makes debugging a bit more tricky. Ultimately, I expect that the failure in
pytestqt/wait_signal.pyis independent ofqtbot, but the reproduction is tricky without it as everything is required to use someQThread.Update: here’s a variant of the issue that does not use
qtbotat all.bug.py:python bug.pygives this expected output:Compiling and running this variant on Linux leads to a Segmentation fault. On Windows, there is no obvious error, but the process finishes pretty much instantly, rather than timing out after 5 seconds as it should. So something is wrong on both OSes.