René's URL Explorer Experiment


Title: Segmentation fault while calling loop.create_future in finalizer (__del__) when a custom sys.excepthook is used · Issue #143 · MagicStack/uvloop · GitHub

Open Graph Title: Segmentation fault while calling loop.create_future in finalizer (__del__) when a custom sys.excepthook is used · Issue #143 · MagicStack/uvloop

X Title: Segmentation fault while calling loop.create_future in finalizer (__del__) when a custom sys.excepthook is used · Issue #143 · MagicStack/uvloop

Description: uvloop version: 0.9.1 Python version: 3.6.5rc1 Platform: linux Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes, in fact, it is reproducible only when the asyncio debug is enabled When using uvloop and having a custom sys.e...

Open Graph Description: uvloop version: 0.9.1 Python version: 3.6.5rc1 Platform: linux Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes, in fact, it is reproducible only when the asyncio debug is enabled Whe...

X Description: uvloop version: 0.9.1 Python version: 3.6.5rc1 Platform: linux Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes, in fact, it is reproducible only when the asyncio debug is enabled Whe...

Opengraph URL: https://github.com/MagicStack/uvloop/issues/143

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Segmentation fault while calling loop.create_future in finalizer (__del__) when a custom sys.excepthook is used","articleBody":"* **uvloop version**: 0.9.1\r\n* **Python version**: 3.6.5rc1\r\n* **Platform**: linux\r\n* **Can you reproduce the bug with `PYTHONASYNCIODEBUG` in env?**: yes, in fact, it is reproducible *only* when the asyncio debug is enabled\r\n\r\nWhen using uvloop and having a custom `sys.excepthook` which uses a variable from the outer scope, which has a finalizer (the `__del__` method) that creates a new future using `AbstractEventLoop.create_future()` method, Python interpreter crashes with a segmentation fault.\r\n\r\nExample code:\r\n```python\r\n#!/usr/bin/env python3\r\nimport asyncio\r\nimport sys\r\n\r\nimport uvloop\r\n\r\nclass LoopWrapper():\r\n    def __init__(self, loop):\r\n        self.loop = loop\r\n\r\n    def __del__(self):\r\n        print('finalizing', self.loop)\r\n        self.loop.create_future()  # assertion fails here\r\n\r\n\r\nasync def store_event_loop(loop):\r\n    wrapped_loop = LoopWrapper(loop)\r\n\r\n    def custom_excepthook(*exc_info):\r\n        print('unhandled_exception', exc_info)\r\n        # commenting the below line causes the failed assertion to disappear\r\n        print(wrapped_loop)\r\n\r\n    sys.excepthook = custom_excepthook\r\n\r\n\r\nif __name__ == '__main__':\r\n    # commenting the below line causes the failed assertion to disappear\r\n    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())\r\n\r\n    event_loop = asyncio.get_event_loop()\r\n    # commenting the below line disables the assertions\r\n    event_loop.set_debug(True)\r\n\r\n    event_loop.run_until_complete(store_event_loop(event_loop))\r\n```\r\n\r\nWhen run, the above example code fails like this:\r\n```\r\n$ ./uvloop_test.py                                                               \r\nfinalizing \u003cuvloop.Loop running=False closed=False debug=True\u003e\r\nSegmentation fault (core dumped)\r\n```\r\n\r\nWhen uvloop is not used, the code fails at this `AttributeError`:\r\n```\r\nTraceback (most recent call last):\r\n  File \"./uvloop_test.py\", line 13, in __del__\r\n  File \"/usr/lib/python3.6/asyncio/base_events.py\", line 276, in create_future\r\nAttributeError: 'NoneType' object has no attribute 'Future'\r\n```\r\n\r\nWhen a Python interpreter compiled with `--with-pydebug` option is used, it crashes on the following assertion failure:\r\n\r\n```\r\npython3: ../Objects/abstract.c:2300: _PyObject_FastCallDict: Assertion `func != NULL' failed.\r\n```\r\n\r\nGDB backtrace (`py-bt`) shows this:\r\n\r\n```\r\n(gdb) py-bt\r\nTraceback (most recent call first):\r\n  \u003cbuilt-in method create_future of Loop object at remote 0x7f7ecfafe048\u003e\r\n  File \"./uvloop_test.py\", line 13, in __del__\r\n    self.loop.create_future()  # assertion fails here\r\n```\r\n\r\nThe issue here is that uvloop causes Python interpreter to crash. I believe that a regular Python exception should be raised instead.\r\n\r\nApart from addressing this issue, if someone can explain the details of what is happening in the example code mentioned above, in particular why it fails even without uvloop and why a finalizer triggered from a custom `sys.excepthook` is not able to call `create_future()`, it would also be helpful.\r\n\r\nThank you.","author":{"url":"https://github.com/pbasista","@type":"Person","name":"pbasista"},"datePublished":"2018-05-16T10:52:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/143/uvloop/issues/143"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:325c927b-aa43-9b67-2a4e-08092363d9f5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id84FA:328262:1CC682:27B0DA:6A5A4529
html-safe-nonce536b0f4d98d89320b92ef8ab7c55cafed11564dbebbbf635c85f632339949e41
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEZBOjMyODI2MjoxQ0M2ODI6MjdCMERBOjZBNUE0NTI5IiwidmlzaXRvcl9pZCI6IjI0OTQwMjE0MzI0OTk2NTE4ODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac1dc2d60a9effd4a85ed1a4564a977b9dc0995878590ac8fab9991ad795e69bde
hovercard-subject-tagissue:323568942
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/MagicStack/uvloop/143/issue_layout
twitter:imagehttps://opengraph.githubassets.com/fc1381bd0ae2eb7a0d124a91f654180773947e7012d9858690784e06d8806e88/MagicStack/uvloop/issues/143
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/fc1381bd0ae2eb7a0d124a91f654180773947e7012d9858690784e06d8806e88/MagicStack/uvloop/issues/143
og:image:altuvloop version: 0.9.1 Python version: 3.6.5rc1 Platform: linux Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes, in fact, it is reproducible only when the asyncio debug is enabled Whe...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepbasista
hostnamegithub.com
expected-hostnamegithub.com
Nonea793cd1fa898929111edad5857ee1f24ecf4bf7702525e67357cabc9df136fc3
turbo-cache-controlno-preview
go-importgithub.com/MagicStack/uvloop git https://github.com/MagicStack/uvloop.git
octolytics-dimension-user_id14324950
octolytics-dimension-user_loginMagicStack
octolytics-dimension-repository_id45766550
octolytics-dimension-repository_nwoMagicStack/uvloop
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id45766550
octolytics-dimension-repository_network_root_nwoMagicStack/uvloop
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release5aec27bb9c4f7ebe5fbbcd1533a5509e63a570a1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/MagicStack/uvloop/issues/143#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FMagicStack%2Fuvloop%2Fissues%2F143
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FMagicStack%2Fuvloop%2Fissues%2F143
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=MagicStack%2Fuvloop
Reloadhttps://github.com/MagicStack/uvloop/issues/143
Reloadhttps://github.com/MagicStack/uvloop/issues/143
Reloadhttps://github.com/MagicStack/uvloop/issues/143
Please reload this pagehttps://github.com/MagicStack/uvloop/issues/143
MagicStack https://github.com/MagicStack
uvloophttps://github.com/MagicStack/uvloop
Notifications https://github.com/login?return_to=%2FMagicStack%2Fuvloop
Fork 611 https://github.com/login?return_to=%2FMagicStack%2Fuvloop
Star 11.9k https://github.com/login?return_to=%2FMagicStack%2Fuvloop
Code https://github.com/MagicStack/uvloop
Issues 126 https://github.com/MagicStack/uvloop/issues
Pull requests 29 https://github.com/MagicStack/uvloop/pulls
Actions https://github.com/MagicStack/uvloop/actions
Projects https://github.com/MagicStack/uvloop/projects
Wiki https://github.com/MagicStack/uvloop/wiki
Security and quality 0 https://github.com/MagicStack/uvloop/security
Insights https://github.com/MagicStack/uvloop/pulse
Code https://github.com/MagicStack/uvloop
Issues https://github.com/MagicStack/uvloop/issues
Pull requests https://github.com/MagicStack/uvloop/pulls
Actions https://github.com/MagicStack/uvloop/actions
Projects https://github.com/MagicStack/uvloop/projects
Wiki https://github.com/MagicStack/uvloop/wiki
Security and quality https://github.com/MagicStack/uvloop/security
Insights https://github.com/MagicStack/uvloop/pulse
Segmentation fault while calling loop.create_future in finalizer (__del__) when a custom sys.excepthook is usedhttps://github.com/MagicStack/uvloop/issues/143#top
https://github.com/pbasista
pbasistahttps://github.com/pbasista
on May 16, 2018https://github.com/MagicStack/uvloop/issues/143#issue-323568942
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.