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
Python 3.6b2 crashes with "Python memory allocator called without holding the GIL" #72657
Comments
The following Python program causes a segfault in Python 3.6b2: import socket
import asyncio
loop = asyncio.get_event_loop()
sock = socket.socket()
sock.close()
async def client():
reader, writer = await asyncio.open_connection(
sock=sock,
loop=loop)
async def runner():
await client()
loop.run_until_complete(runner()) |
Fatal Python error: Python memory allocator called without holding the GIL Current thread 0x00007fffb043b3c0 (most recent call first): |
And here's an OS X debug-build stack trace using the system malloc (current 3.6 tip, a218260334c4): Thread 0 Crashed:: Dispatch queue: com.apple.main-thread |
internal_setblocking() sets an exception w/o holding the GIL. #0 0x00007ffff711f6f5 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54 |
I have a patch already, writing a unittest. |
It's my fault. I added the "goto error" w/o realizing that I forgot to re-acquire the GIL. |
Attaching a patch to fix this. Please review. |
LGTM, thanks Yury! |
NP :) Should this be committed to 3.6/default, or in 3.5 too? |
3.5 is not affected by the crasher. I only added the error check to default (3.6). |
Oh, I didn't expect that my new check would catch such bug. Nice. In release mode, the check is disabled by default (can be enabled at But the bug should be fixed anyway :-) |
New changeset 4b5b233d4c98 by Yury Selivanov in branch '3.6': New changeset 554fb699af8c by Yury Selivanov in branch 'default': |
It actually crashed in release mode for me. Maybe the exact location of SF was different, but whatever... Anyways, closing the issue. Thanks for the review Christian! |
I'm curious. I tested in release mode, the example does crash: $ ./python x.py
Segmentation fault (core dumped) I'm able to get a Python traceback using PYTHONMALLOC=debug: $ PYTHONMALLOC=debug ./python x.py
Fatal Python error: Python memory allocator called without holding the GIL Current thread 0x00007f65bd74b700 (most recent call first): |
Well, since the GIL wasn't properly acquired, it's only a matter of time until something else crashes. |
New changeset 2fd92794f775 by Martin Panter in branch '3.6': |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: