Title: `_remote_debugging`: Missing `last_profiled_frame` updates in coroutines, generators, etc. · Issue #151436 · python/cpython · GitHub
Open Graph Title: `_remote_debugging`: Missing `last_profiled_frame` updates in coroutines, generators, etc. · Issue #151436 · python/cpython
X Title: `_remote_debugging`: Missing `last_profiled_frame` updates in coroutines, generators, etc. · Issue #151436 · python/cpython
Description: Bug report Bug description: Very similar to #151424, but this is not about impossible stack traces but implausible. :-) Found while wrapping my head around #151424 and checking the source code for internals of last_profiled_frame. Mechan...
Open Graph Description: Bug report Bug description: Very similar to #151424, but this is not about impossible stack traces but implausible. :-) Found while wrapping my head around #151424 and checking the source code for ...
X Description: Bug report Bug description: Very similar to #151424, but this is not about impossible stack traces but implausible. :-) Found while wrapping my head around #151424 and checking the source code for ...
Opengraph URL: https://github.com/python/cpython/issues/151436
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`_remote_debugging`: Missing `last_profiled_frame` updates in coroutines, generators, etc.","articleBody":"# Bug report\n\n### Bug description:\n\nVery similar to #151424, but this is not about impossible stack traces but implausible. :-)\n\nFound while wrapping my head around #151424 and checking the source code for internals of `last_profiled_frame`.\n\n# Mechansim\n\nThe interpr has to advance `tstate->last_profiled_frame` for us. It does so in `_PyEval_FrameClearAndPop`:\n\nhttps://github.com/python/cpython/blob/f4f102027a9b0edc72a048f17b696aa92d2e6893/Python/ceval.c#L1981\n\nBut the helper not always used when a frame is removed from the chain.\n\nNaively:\n\n`_YIELD_VALUE` missed:\n\nhttps://github.com/python/cpython/blob/f4f102027a9b0edc72a048f17b696aa92d2e6893/Python/bytecodes.c#L1863-L1864\n\n`RETURN_GENERATOR` missed:\n\nhttps://github.com/python/cpython/blob/f4f102027a9b0edc72a048f17b696aa92d2e6893/Python/bytecodes.c#L5877\n\n`_gen_throw` missed:\n\nhttps://github.com/python/cpython/blob/f4f102027a9b0edc72a048f17b696aa92d2e6893/Objects/genobject.c#L684\nhttps://github.com/python/cpython/blob/f4f102027a9b0edc72a048f17b696aa92d2e6893/Objects/genobject.c#L704\n\nframe-init fail missed:\n\nhttps://github.com/python/cpython/blob/f4f102027a9b0edc72a048f17b696aa92d2e6893/Python/ceval.c#L2009\n\n# Reproduction\n\n```python\ndef gen():\n while True:\n n = yield\n sum(range(n))\n\ng = gen()\nnext(g)\n\ndef drv_a(): g.send(5000)\ndef drv_b(): g.send(50000)\n\nwhile True:\n drv_a(); drv_b()\n```\n\n```bash\n2026-06-13T11:41:14.582916000+0200 maurycy@gimel /Users/maurycy/work/cpython-main (main f4f1020?) % sudo ./python.exe -m profiling.sampling run --collapsed -o /tmp/stacks.txt -d 10 genrepro.py&& cat /tmp/stacks.txt\nCaptured 10,000 samples in 10.00 seconds\nSample rate: 999.99 samples/sec\nError rate: 0.01\nCollapsed stack output written to /tmp/stacks.txt\ntid:13788812;\u003cfrozen runpy>:_run_module_as_main:201;\u003cfrozen runpy>:_run_code:87;genrepro.py:\u003cmodule>:13;genrepro.py:drv_b:10;genrepro.py:gen:4 9990\ntid:13788812;\u003cfrozen runpy>:_run_module_as_main:201;\u003cfrozen runpy>:_run_code:87;genrepro.py:\u003cmodule>:13;genrepro.py:drv_b:10;genrepro.py:gen:3 6\ntid:13788812;\u003cfrozen runpy>:_run_module_as_main:201;\u003cfrozen runpy>:_run_code:87;genrepro.py:\u003cmodule>:13 3\n2026-06-13T11:41:27.285300000+0200 maurycy@gimel /Users/maurycy/work/cpython-main (main f4f1020?) %\n```\n\nWhere is `drv_a`? `TOTALLY_GONE`.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-151437\n* gh-151612\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/maurycy","@type":"Person","name":"maurycy"},"datePublished":"2026-06-13T09:42:35Z","url":"https://github.com/python/cpython/issues/151436"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c1f70bca-12ee-7e2c-9708-0bcdc3a7bcc1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E802:17FB7:3ACDC0A:4A75B06:6B023366 |
| html-safe-nonce | 0eeae885f3b109d5a64d3b0f3fd3b0f363744407cb58b982a24a3650c9e7296a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODAyOjE3RkI3OjNBQ0RDMEE6NEE3NUIwNjo2QjAyMzM2NiIsInZpc2l0b3JfaWQiOiI4NTMxNjMxOTgwNDE1MTY5MzgyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | dc4e51d979ebfaa8c9f764b7bebb73dd7a5fadbf71edbd8952ed9b76f6e7e60f |
| hovercard-subject-tag | issue:4655089009 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/151436/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d78db3fb7be3e64e5472c8a9d85ee7ee52921e698d6b56cae8b6cbc5d9ffdbc1/python/cpython/issues/151436 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d78db3fb7be3e64e5472c8a9d85ee7ee52921e698d6b56cae8b6cbc5d9ffdbc1/python/cpython/issues/151436 |
| og:image:alt | Bug report Bug description: Very similar to #151424, but this is not about impossible stack traces but implausible. :-) Found while wrapping my head around #151424 and checking the source code for ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | maurycy |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width