Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error on thread creation in low memory condition: local storage #52444

Closed
vstinner opened this issue Mar 22, 2010 · 2 comments
Closed

Fatal error on thread creation in low memory condition: local storage #52444

vstinner opened this issue Mar 22, 2010 · 2 comments
Labels
type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@vstinner
Copy link
Member

BPO 8197
Nosy @vstinner

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 = None
closed_at = <Date 2010-09-10.22:29:29.420>
created_at = <Date 2010-03-22.01:08:22.931>
labels = ['type-crash']
title = 'Fatal error on thread creation in low memory condition: local storage'
updated_at = <Date 2010-09-10.22:29:29.419>
user = 'https://github.com/vstinner'

bugs.python.org fields:

activity = <Date 2010-09-10.22:29:29.419>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2010-09-10.22:29:29.420>
closer = 'vstinner'
components = []
creation = <Date 2010-03-22.01:08:22.931>
creator = 'vstinner'
dependencies = []
files = []
hgrepos = []
issue_num = 8197
keywords = []
message_count = 2.0
messages = ['101474', '116052']
nosy_count = 1.0
nosy_names = ['vstinner']
pr_nums = []
priority = 'low'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = 'crash'
url = 'https://bugs.python.org/issue8197'
versions = ['Python 2.7', 'Python 3.2']

@vstinner
Copy link
Member Author

I wrote a patch to preallocate Python thread state before creating the thread to avoid a fatal error: bpo-7544 (it's now closed). This patch is not enough to avoid fatal errors in low memory condition.

Just after the creation of the thread, _PyGILState_NoteThreadState() is called. This function can fail with a fatal error (Couldn't create autoTLSkey mapping) in low memory condition if a memory allocation fails in find_key(), called by PyThread_set_key_value().

PyThread_set_key_value() fills a global single linked list of type 'struct key', the head is 'keyhead'. This list contains values and uses an index composed of (long thread id, int key). Only one key is used: autoTLSkey (0). The list is used to get the thread state (eg. in PyGILState_Ensure).

Note: This issue is very unlikely, but it does exist :-)

@vstinner vstinner added the type-crash A hard crash of the interpreter, possibly with a core dump label Mar 22, 2010
@vstinner vstinner changed the title Fatal error on thread creation in low memory condition (2) Fatal error on thread creation in low memory condition: local storage Mar 22, 2010
@vstinner
Copy link
Member Author

I don't know how to fix this issue, and I don't know if it can be fixed. As the issue is very unlikely, I prefer to close it.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

1 participant