New submission from Arcadiy Ivanov <arca...@ivanov.biz>: While working on GH gevent/gevent#993 I've encountered a stall trying to read from an mp.Queue passed to mp.Process's target as an argument. Trying to print out the lock state in child process I encountered as SEGV in Lock's __repr__. I originally thought it was due to gevent/greenlet stack magic, but it wasn't.
This happens when `fork` context Queue (default) is used with `spawn` context Process (obvious stupidity on my part, alas shouldn't crash). Python 3.6.4 from PyEnv Fedora 27 ``` $ python test_lock_sigsegv.py Parent r_q: <Lock(owner=None)>, <Lock(owner=None)>, <BoundedSemaphore(value=2147483647, maxvalue=2147483647)> -11 ``` ``` Program terminated with signal SIGSEGV, Segmentation fault. #0 __new_sem_getvalue (sem=0x7fc877f54000, sval=sval@entry=0x7fffb130db9c) at sem_getvalue.c:38 38 *sval = atomic_load_relaxed (&isem->data) & SEM_VALUE_MASK; ... #0 __new_sem_getvalue (sem=0x7fc877f54000, sval=sval@entry=0x7fffb130db9c) at sem_getvalue.c:38 #1 0x00007f1116aeb202 in semlock_getvalue (self=<optimized out>) at /tmp/python-build.20171219170845.6548/Python-3.6.4/Modules/_multiprocessing/semaphore.c:531 ``` At a minimum I think there should be a check trying to reduce arguments via incompatible context's process to prevent a SEGV. Test attached. ---------- components: Library (Lib) files: test_lock_sigsegv.py messages: 314762 nosy: arcivanov priority: normal severity: normal status: open title: SEGV in mp.synchronize.Lock.__repr__ in spawn'ed proc if ctx mismatched type: crash versions: Python 3.6 Added file: https://bugs.python.org/file47510/test_lock_sigsegv.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33196> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com