homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pthread_kill() doesn't work on the main thread on FreeBSD6
Type: Stage:
Components: Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: neologix, python-dev, vstinner
Priority: normal Keywords: patch

Created on 2011年06月23日 22:56 by vstinner, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
thread_init_freebsd6.patch vstinner, 2011年06月23日 22:58 review
pthread_kill_main_thread.diff neologix, 2011年06月24日 18:05 review
Messages (8)
msg138875 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011年06月23日 22:56
pthread_kill() doesn't work on the main thread on FreeBSD6: sending a signal to the main thread does nothing. It works on the main thread just after the creation of the first thread.
PyThread__init_thread() has 3 implementations in Python/thread_pthread.h:
 - call pthread_init()
 - create a dummy thread (no-op) and join it
 - do nothing
pthread_init() doesn't exist on FreeBSD6. If the dummy thread implementation is used, pthread_kill() works directly on the main thread at startup.
msg138876 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011年06月23日 22:58
Attached patch implements the suggested fix.
msg138877 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011年06月23日 23:06
FreeBSD 7 is not affected by this issue.
To test this issue, call signal.pthread_kill(threading.get_ident(), signal.SIGINT) in an interpreter: it should raise a KeyboardInterrupt. On FreeBSD6, it does nothing. Or run ./python -m test -v test_signal: test_pendings hangs because the test reads 3 bytes from a pipe whereas the pipe is empty. The write end is non blocking, but the read end is blocking.
It would be possible to fix the test to fail instead of blocking: set the read end as non blocking (setUp() does always set the write end as non blocking).
msg138970 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2011年06月24日 18:05
> Attached patch implements the suggested fix.
The patch looks good to me.
> It would be possible to fix the test to fail instead of blocking
I think this issue deserves a specific test, since:
- test_pending tests something completely different
- at the time test_pending gets to run, there's a high chance that
threads have already been created
I've attached a patch spawning a new interpreter to test that.
msg138973 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011年06月24日 18:53
New changeset 024827a9db64 by Victor Stinner in branch 'default':
Issue #12392: fix thread initialization on FreeBSD 6
http://hg.python.org/cpython/rev/024827a9db64 
msg138974 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011年06月24日 18:53
> I've attached a patch spawning a new interpreter to test that.
Thanks, I commited your test at the same time of the fix.
msg139596 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011年07月01日 19:29
This issue introduced regressions in the faulthandler module: see issue #12469.
msg139806 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011年07月04日 20:57
As discussed in issue #12469, the commit 024827a9db64 makes things worse: it changes the behaviour of many functions related to signal handling (e.g. sigwait()) just to be able to use pthread_kill() on the main thread. I reverted the patch: commit 34061f0d35ba.
History
Date User Action Args
2022年04月11日 14:57:18adminsetgithub: 56601
2011年11月08日 17:31:01floxsetmessages: - msg147102
2011年11月05日 16:55:20python-devsetmessages: + msg147102
2011年07月04日 20:57:57vstinnersetmessages: + msg139806
2011年07月01日 19:29:03vstinnersetmessages: + msg139596
2011年06月26日 20:29:28vstinnersetstatus: open -> closed
resolution: fixed
2011年06月24日 18:53:55vstinnersetmessages: + msg138974
2011年06月24日 18:53:29python-devsetnosy: + python-dev
messages: + msg138973
2011年06月24日 18:05:49neologixsetfiles: + pthread_kill_main_thread.diff

messages: + msg138970
2011年06月23日 23:06:06vstinnersetmessages: + msg138877
2011年06月23日 22:58:36vstinnersetfiles: + thread_init_freebsd6.patch
keywords: + patch
messages: + msg138876
2011年06月23日 22:56:01vstinnercreate

AltStyle によって変換されたページ (->オリジナル) /