Daniel Birnstiel added the comment:

While you might scold me for the following code, it is just some fiddling with 
the cpython functions from python side.

Backstory is issue 6721 or related to it. I am working on a multi-process 
service which uses multiprocessing (or rather the billiard fork). While forking 
I run into deadlocks as described in the issue when I fork while the io lock is 
acquired.

In order to find a solution I experimented with the cpython module and tried to 
release the lock manually after a fork. The code can be found attached (tested 
with python 3.6/3.7 on OSX Sierra). While it does not really do what it is 
supposed to do, it shows the problem described in this issue (#29859):

If the internal calls to the pthread_* functions fail, I will only get a 
generic error message:

pthread_mutex_lock[3]: Undefined error: 0
pthread_cond_signal: Undefined error: 0
pthread_mutex_unlock[3]: Undefined error: 0

In reality the produced error messages should be:

pthread_mutex_lock[3]: Invalid argument
pthread_cond_signal: Invalid argument
pthread_mutex_unlock[3]: Invalid argument

This happens because the pthread_* functions do not set the erno variable as 
described in the issue description.

Please note that the issue is not only related to my code, but might affect all 
code using locks. While I suppose there shouldn't be any errors when calling 
the low level functions, the attached patch/pr will make debugging a lot easier 
when it actually happens by displaying the correct error message.

----------
Added file: http://bugs.python.org/file46749/test.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29859>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to