classification
Title: Deadlock with writing to stderr from forked process
Type: Stage: resolved
Components: Interpreter Core, IO Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Locks in the standard library should be sanitized on fork
View: 6721
Assigned To: Nosy List: ionelmc, neologix, nirs, serhiy.storchaka
Priority: normal Keywords:

Created on 2014-10-22 13:59 by ionelmc, last changed 2014-11-02 15:45 by serhiy.storchaka. This issue is now closed.

Messages (5)
msg229825 - (view) Author: Ionel Cristian Mărieș (ionelmc) Date: 2014-10-22 13:59
Example code:

import os
import sys
import threading


def run():
    sys.stderr.write("in parent thread\n")

threading.Thread(target=run).start()
pid = os.fork()
if pid:
    os.waitpid(pid, 0)
else:
    sys.stderr.write("in child\n")


To run:  while python3 deadlock.py; do; done        

Note: does not reproduce if ran with `python -u` (unbuffered)
msg230470 - (view) Author: Nir Soffer (nirs) * Date: 2014-11-01 23:40
This is a duplicate of http://bugs.python.org/issue6721
msg230489 - (view) Author: Ionel Cristian Mărieș (ionelmc) Date: 2014-11-02 15:23
Serhiy, I don't think this is a duplicate. Odd that you closed this without any explanation.

This happens in a internal lock in cpython's runtime, while the other bug is about locks used in the logging module (which are very different).
msg230493 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2014-11-02 15:44
> Maries Ionel Cristian added the comment:
>
> Serhiy, I don't think this is a duplicate. Odd that you closed this without any explanation.
>
> This happens in a internal lock in cpython's runtime, while the other bug is about locks used in the logging module (which are very different).

Yes, this is a duplicate. Whether the lock is an internal or a user-created one doesn't change anything, it's always the same problem of having a lock locked by another thread at the time of the fork().
msg230494 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-11-02 15:45
Sorry. I thought issue6721 is more general, not just about the logging module.
History
Date User Action Args
2014-11-02 15:45:41serhiy.storchakasetmessages: + msg230494
2014-11-02 15:44:19neologixsetstatus: open -> closed
resolution: duplicate
messages: + msg230493
2014-11-02 15:23:01ionelmcsetstatus: closed -> open
resolution: duplicate -> (no value)
messages: + msg230489
2014-11-02 15:11:51serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
resolution: duplicate
superseder: Locks in the standard library should be sanitized on fork
stage: resolved
2014-11-01 23:40:28nirssetnosy: + nirs
messages: + msg230470
2014-10-24 22:48:19pitrousetnosy: + neologix
2014-10-22 13:59:27ionelmccreate