Try outputting core dump when multiprocessing spawn segfaults

This commit is contained in:
Kovid Goyal 2024-03-14 16:19:33 +05:30
parent 7821ae39ab
commit 86c59016c6
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -67,13 +67,25 @@ def get_process_pool_executor(
def test_spawn() -> None:
monkey_patch_multiprocessing()
import shutil
import subprocess
from queue import Empty
try:
from multiprocessing import get_context
ctx = get_context('spawn')
q = ctx.Queue()
p = ctx.Process(target=q.put, args=('hello',))
p.start()
x = q.get(timeout=8)
try:
x = q.get(timeout=8)
except Empty:
p.join()
rc = p.exitcode
if rc == 0:
raise TimeoutError('Timed out waiting for response from spawned process')
if shutil.which('coredumpctl'):
subprocess.run(['sh', '-c', 'echo bt | coredumpctl debug'])
raise SystemExit(f'Spawned process exited with return code: {rc}')
assert x == 'hello'
p.join()
finally: