You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Check for main interpreter when checking for "main" thread (for signal handling) #79905
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/ericsnowcurrently'closed_at=<Date2019-02-23.22:41:49.385>created_at=<Date2019-01-11.21:04:47.065>labels= ['interpreter-core', 'type-bug', '3.8']
title='Check for main interpreter when checking for "main" thread (for signal handling)'updated_at=<Date2019-02-23.22:41:49.385>user='https://github.com/ericsnowcurrently'
The code in Modules/signalsmodule.c (as well as a few other places in the code) has a concept of a "main" thread. It's the OS thread where Py_Initialize() was called (and likely the process's original thread). For various good reasons, we ensure that signal handling happens relative to that ("main") thread.
The problem is that we track the OS thread (by ID), which multiple interpreters can share. What we really want is to track the original PyThreadState. Otherwise signal-handling could happen (or handlers get added) in the wrong interpreter.
Options:
track the PyThreadState pointer instead of the OS thread ID
check that the current interpreter is the main one, in every place we check for the main thread
Activity
ericsnowcurrently commentedon Jan 11, 2019
The code in Modules/signalsmodule.c (as well as a few other places in the code) has a concept of a "main" thread. It's the OS thread where Py_Initialize() was called (and likely the process's original thread). For various good reasons, we ensure that signal handling happens relative to that ("main") thread.
The problem is that we track the OS thread (by ID), which multiple interpreters can share. What we really want is to track the original PyThreadState. Otherwise signal-handling could happen (or handlers get added) in the wrong interpreter.
Options:
From what I can tell, the simpler option is #2.
ericsnowcurrently commentedon Feb 23, 2019
New changeset 64d6cc8 by Eric Snow in branch 'master':
bpo-35724: Explicitly require the main interpreter for signal-handling. (GH-11530)
64d6cc8