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

_asyncio extensions crashes if initialized multiple times in same process #84595

Closed
indygreg mannequin opened this issue Apr 28, 2020 · 2 comments
Closed

_asyncio extensions crashes if initialized multiple times in same process #84595

indygreg mannequin opened this issue Apr 28, 2020 · 2 comments
Labels
3.8 only security fixes 3.9 only security fixes topic-asyncio

Comments

@indygreg
Copy link
Mannequin

indygreg mannequin commented Apr 28, 2020

BPO 40415
Nosy @vstinner, @asvetlov, @1st1, @indygreg
Superseder
  • bpo-40294: Use-after-free crash if multiple interpreters import asyncio module
  • 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 2020-04-28.02:30:45.940>
    created_at = <Date 2020-04-28.02:27:25.057>
    labels = ['3.8', '3.9', 'expert-asyncio']
    title = '_asyncio extensions crashes if initialized multiple times in same process'
    updated_at = <Date 2020-04-28.12:44:07.315>
    user = 'https://github.com/indygreg'

    bugs.python.org fields:

    activity = <Date 2020-04-28.12:44:07.315>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-04-28.02:30:45.940>
    closer = 'indygreg'
    components = ['asyncio']
    creation = <Date 2020-04-28.02:27:25.057>
    creator = 'indygreg'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40415
    keywords = []
    message_count = 2.0
    messages = ['367483', '367484']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'asvetlov', 'yselivanov', 'indygreg']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '40294'
    type = None
    url = 'https://bugs.python.org/issue40415'
    versions = ['Python 3.8', 'Python 3.9']

    @indygreg
    Copy link
    Mannequin Author

    indygreg mannequin commented Apr 28, 2020

    Most of CPython's extensions can be initialized and freed multiple times in the same process. However, _asyncio crashes on at least CPython 3.8.2 when this is done.

    STR:

    1. Create a new Python interpreter
    2. Have it import _asyncio
    3. Finalize that interpreter.
    4. Create a new Python interpreter
    5. Have it import _asyncio

    There are probably STR in pure Python by forcing _imp.create_dynamic() to run multiple times after the module is unloaded.

    The crash occurs due to unchecked NULL access in Py_INCREF(all_tasks); in PyInit__asyncio().

    I think the underlying problem is module_init() is short-circuiting because module_initialized is set. And module_initialized is set on subsequent module loads because module_free() isn't clearing it.

    @indygreg indygreg mannequin added 3.8 only security fixes 3.9 only security fixes topic-asyncio labels Apr 28, 2020
    @indygreg
    Copy link
    Mannequin Author

    indygreg mannequin commented Apr 28, 2020

    Oh, I just went to patch this and it is a dupe of 40294, which has already been fixed and backported.

    @indygreg indygreg mannequin closed this as completed Apr 28, 2020
    @indygreg indygreg mannequin closed this as completed Apr 28, 2020
    @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
    3.8 only security fixes 3.9 only security fixes topic-asyncio
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants