Skip to content

Instantly share code, notes, and snippets.

@ulope
Last active November 6, 2018 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulope/db811b6cf853ff267f27e4295bc4739e to your computer and use it in GitHub Desktop.
Save ulope/db811b6cf853ff267f27e4295bc4739e to your computer and use it in GitHub Desktop.
# This causes Python to crash with
# `SystemError: Objects/tupleobject.c:851: bad argument to internal function`
# within a few hundered iterations at most. Typically only a handful are needed though.
# Most likely reason is: https://bugs.python.org/issue15108
from io import StringIO
import gevent
gevent.config.monitor_thread = True
# Silence monitor output
gevent.get_hub().exception_stream = StringIO()
def worker():
i = 0
while True:
tuple(j for j in range(5000000))
i += 1
print(i)
gevent.spawn(worker).join()
@ulope
Copy link
Author

ulope commented Nov 6, 2018

Traceback:

Traceback (most recent call last):
  File "/Users/ulo/t/gevent_crash_tuple.py", line 24, in <module>
    gevent.spawn(worker).join()
  File "src/gevent/greenlet.py", line 661, in gevent._greenlet.Greenlet.join
  File "src/gevent/greenlet.py", line 687, in gevent._greenlet.Greenlet.join
  File "src/gevent/greenlet.py", line 676, in gevent._greenlet.Greenlet.join
  File "src/gevent/_greenlet_primitives.py", line 59, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 63, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/__greenlet_primitives.pxd", line 35, in gevent.__greenlet_primitives._greenlet_switch
SystemError: Objects/tupleobject.c:851: bad argument to internal function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment