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.

Author Jason McKellar
Recipients Jason McKellar, asvetlov, yselivanov
Date 2018-06-06.01:17:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1528247864.26.0.592728768989.issue33776@psf.upfronthosting.co.za>
In-reply-to
Content
If time.monotonic() is yielded from a generator that is passed to asyncio.ensure_future a segfault occurs when it's scheduled. 

The example below shows time.monotonic called in the generator, however the segfault will also occur if a function is called (not a lambda) that uses time.monotonic.

I've tested on Python 3.6 and 3.7.0b4.


For example:

import asyncio
import time
import faulthandler

faulthandler.enable()

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

# Note that ensure_future argument is generator
# which yields time.monotonic() return value
tasks = [asyncio.ensure_future(
    time.monotonic()
    for i in range(1)
)]
results_future = asyncio.gather(*tasks)

# Segmentation fault
results = loop.run_until_complete(results_future)


The fault handler output:

Fatal Python error: Segmentation fault

Current thread 0x00007f4b7a042b88 (most recent call first):
  File "/usr/local/lib/python3.7/asyncio/events.py", line 88 in _run
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 1738 in _run_once
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 521 in run_forever
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 553 in run_until_complete
  File "/test-seg.py", line 19 in <module>
Segmentation fault (core dumped)


An example with time.monotonic call nested in a function:

import asyncio
import time
import faulthandler

def bad():
    return {'nested': time.monotonic()}

faulthandler.enable()

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

tasks = [asyncio.ensure_future(
    bad()
    for i in range(1)
)]
results_future = asyncio.gather(*tasks)

# Segmentation fault
results = loop.run_until_complete(results_future)
History
Date User Action Args
2018-06-06 01:17:45Jason McKellarsetrecipients: + Jason McKellar, asvetlov, yselivanov
2018-06-06 01:17:44Jason McKellarsetmessageid: <1528247864.26.0.592728768989.issue33776@psf.upfronthosting.co.za>
2018-06-06 01:17:40Jason McKellarlinkissue33776 messages
2018-06-06 01:17:26Jason McKellarcreate