Skip to content

Possible to double deref when exiting a context #157015

Description

@AZero13

Crash report

What happened?

There was a Use-After-Free and double-decref bug in _PyContext_Exit() in Python/context.c. The function was calling Py_SETREF(ts->context, (PyObject *)ctx->ctx_prev) before clearing the ctx->ctx_prev and ctx->ctx_entered internal states.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Output from running 'python -VV' on the command line:

No response

Linked PRs

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedtype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions