Skip to content

[BUG] Cython/Utility/Profile.c use of use_tracing broken by recent Python 3.10 change #4153

Closed

Description

@jmarshall

Describe the bug
Cython/Utility/Profile.c uses tstate->use_tracing but a recent change in the upcoming Python 3.10 has moved this field down to a new tstate->cframe->use_tracing location, leading to Profile.c failing to compile. See python/cpython#25276 and bpo-43760.

To Reproduce
Code to reproduce the behaviour:
N.A. (essentially any, if # cython: profile=True or linetrace=True is activated)

Expected behavior
Cython-using code compiles successfully.

Environment (please complete the following information):

  • OS: observed on Linux
  • Python version: 3.10
  • Cython version: problem present in master

Additional context
Reported on a Cython-using project as pysam-developers/pysam#1015.

Activity

  1. jmarshall commented on May 11, 2021

    @jmarshall
    Author

    bpo-43760 is freshly active and has suggested the possibility of introducing accessor functions, but is mostly at the stage of finding out what the reasons are for code outwith CPython wanting to directly access use_tracing.

  2. hroncok commented on May 19, 2021

    @hroncok
    Contributor

    I'm attempting to get a working solution (even if temporary) in #4173

  3. scoder commented on May 19, 2021

    @scoder
    Contributor

    This is already resolved for master in
    c9cccfe
    78f1ca8

  4. hroncok commented on May 19, 2021

    @hroncok
    Contributor

    Should I attempt a backport instead then?

  5. scoder commented on May 19, 2021

    @scoder
    Contributor

    The change applies cleanly to 0.29.x as well. I'll push it there. Sorry for the duplicate effort.

  6. added this to the 0.29.24 milestone on May 19, 2021
  7. pablogsal commented on Sep 23, 2021

    @pablogsal
    Contributor

    This may be dangerous for two reasons:

    1. tstate->use_tracing had global effect before, while tstate->cframe->use_tracing only affects the last executing frame. Modifiying this value only affects that particular frame. The semantics are different.
    2. tstate->cframe points to a stack allocated variable in ceval. Accessing this from heap objects may be dangerous.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions