On windows, running the below code with Python or pytest makes it print out Windows fatal exception: access violation
(but the script will continue with no issue)
Reproduction:
import multiprocessing as mp
import faulthandler
faulthandler.enable()
def dummy_function():
import os
print(f"Worker PID: {os.getpid()}")
print("Worker process completed")
def test_reproduce():
p = mp.Process(target=dummy_function)
p.start()
p.join()
print(f"Process exit code: {p.exitcode}")
if __name__ == "__main__":
print("Direct run:")
test_reproduce()
print("Success")
Trace:
Windows fatal exception: access violation
Current thread 0x00000f48 (most recent call first):
File "C:\Python\cpython-3.10.16-windows-x86_64-none\lib\multiprocessing\popen_spawn_win32.py", line 73 in __init__
File "C:\Python\cpython-3.10.16-windows-x86_64-none\lib\multiprocessing\context.py", line 336 in _Popen
File "C:\Python\cpython-3.10.16-windows-x86_64-none\lib\multiprocessing\context.py", line 224 in _Popen
File "C:\Python\cpython-3.10.16-windows-x86_64-none\lib\multiprocessing\process.py", line 121 in start
File "C:\src\sandbox\minimal.py", line 5 in test_reproduce
This points to the _winapi.CreateProcess()
function.
Note that if faulthandler
is not enabled, this will not be shown to the user when running with Python, whereas Pytest enables the faulthandler
for you.
Happens on two of my computers, Windows 11 and Windows 10. Python 3.10 and Python 3.12. This has definitely also worked before so I am not sure what has changed.
This was caused by our antivirus, SentinelOne agent. Disabling it got rid of this error printout, reenabling it brought it back.