René's URL Explorer Experiment


Title: _remote_debugging frame cache can reuse stale frame anchors · Issue #151613 · python/cpython · GitHub

Open Graph Title: _remote_debugging frame cache can reuse stale frame anchors · Issue #151613 · python/cpython

X Title: _remote_debugging frame cache can reuse stale frame anchors · Issue #151613 · python/cpython

Description: The remote debugging frame cache uses last_profiled_frame as an address anchor, so it can hit an ABA case when a frame address is reused after the old frame has returned. A profiler sample can then validate against the same address but a...

Open Graph Description: The remote debugging frame cache uses last_profiled_frame as an address anchor, so it can hit an ABA case when a frame address is reused after the old frame has returned. A profiler sample can then...

X Description: The remote debugging frame cache uses last_profiled_frame as an address anchor, so it can hit an ABA case when a frame address is reused after the old frame has returned. A profiler sample can then...

Opengraph URL: https://github.com/python/cpython/issues/151613

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"_remote_debugging frame cache can reuse stale frame anchors","articleBody":"The remote debugging frame cache uses `last_profiled_frame` as an address anchor, so it can hit an ABA case when a frame address is reused after the old frame has returned. A profiler sample can then validate against the same address but append cached parent frames from a previous stack, producing impossible mixed stacks such as a `b_leaf` frame with an `a_parent` caller. PR #151437 fixes missing anchor updates, but the cache should also distinguish reused frame addresses, for example by pairing the anchor with a monotonic sequence, so cached continuations are only reused for the exact frame instance previously sampled.\n\nI confirmed the following standalone reproducer. It repeatedly samples a process that alternates between two separate call chains. Seeing names from both chains in one sampled stack is impossible unless cached parent frames were spliced onto the wrong live frame.\n\n```python\nimport contextlib\nimport os\nimport socket\nimport subprocess\nimport sys\nimport tempfile\nimport textwrap\n\nfrom _remote_debugging import PROCESS_VM_READV_SUPPORTED, RemoteUnwinder\n\nTRANSIENT_ERRORS = (OSError, RuntimeError, UnicodeDecodeError)\n\nif sys.platform != \"linux\" or not PROCESS_VM_READV_SUPPORTED:\n    raise SystemExit(\"requires Linux with process_vm_readv support\")\n\n\ndef find_free_port():\n    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:\n        sock.bind((\"localhost\", 0))\n        return sock.getsockname()[1]\n\n\ndef wait_for(sock, expected):\n    sock.settimeout(10.0)\n    data = b\"\"\n    while expected not in data:\n        chunk = sock.recv(4096)\n        if not chunk:\n            raise RuntimeError(f\"target exited before {expected!r}\")\n        data += chunk\n\n\nport = find_free_port()\ntarget = f\"\"\"\\\nimport socket\n\nsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\nsock.connect((\"localhost\", {port}))\nsock.sendall(b\"ready\")\n\ndef burn_a():\n    total = 0\n    for i in range(20000):\n        total += i\n    return total\n\ndef burn_b():\n    total = 0\n    for i in range(20000):\n        total += i\n    return total\n\ndef a_leaf():\n    return burn_a()\n\ndef b_leaf():\n    return burn_b()\n\ndef a_parent():\n    return a_leaf()\n\ndef b_parent():\n    return b_leaf()\n\nwhile True:\n    a_parent()\n    b_parent()\n\"\"\"\n\nwith tempfile.TemporaryDirectory() as tmp:\n    script = os.path.join(tmp, \"target.py\")\n    with open(script, \"w\", encoding=\"utf-8\") as f:\n        f.write(textwrap.dedent(target))\n\n    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n    server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n    server.bind((\"localhost\", port))\n    server.listen(1)\n    server.settimeout(10.0)\n\n    proc = subprocess.Popen([sys.executable, script])\n    conn = None\n    try:\n        conn, _ = server.accept()\n        wait_for(conn, b\"ready\")\n        unwinder = RemoteUnwinder(\n            proc.pid, all_threads=True, cache_frames=True, stats=True\n        )\n        branch_a = {\"a_parent\", \"a_leaf\", \"burn_a\"}\n        branch_b = {\"b_parent\", \"b_leaf\", \"burn_b\"}\n\n        for sample in range(1, 8001):\n            with contextlib.suppress(*TRANSIENT_ERRORS):\n                traces = unwinder.get_stack_trace()\n                for interp in traces:\n                    for thread in interp.threads:\n                        funcs = [frame.funcname for frame in thread.frame_info]\n                        names = set(funcs)\n                        if branch_a & names and branch_b & names:\n                            print(f\"mixed stack found at sample {sample}\")\n                            print(funcs)\n                            print(unwinder.get_stats())\n                            raise SystemExit(1)\n\n        print(\"no mixed stack found\")\n        print(unwinder.get_stats())\n    finally:\n        if conn is not None:\n            conn.close()\n        server.close()\n        proc.kill()\n        proc.wait(timeout=10.0)\n```\n\nOn the unfixed build, this reproduced for me with this output:\n\n```text\nmixed stack found at sample 5904\n['b_leaf', 'a_parent', '\u003cmodule>']\n{'total_samples': 5904, 'frame_cache_hits': 5887, 'frame_cache_misses': 13, 'frame_cache_partial_hits': 3, 'frames_read_from_cache': 17666, 'frames_read_from_memory': 5942, 'memory_reads': 11889, 'memory_bytes_read': 5722200, 'code_object_cache_hits': 5947, 'code_object_cache_misses': 7, 'stale_cache_invalidations': 0, 'batched_read_attempts': 5903, 'batched_read_successes': 5903, 'batched_read_misses': 0, 'batched_read_segments_requested': 17709, 'batched_read_segments_completed': 17709, 'frame_cache_hit_rate': 99.7797729967813, 'code_object_cache_hit_rate': 99.88243197850184, 'batched_read_success_rate': 100.0, 'batched_read_segment_completion_rate': 100.0}\n```\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-151614\n* gh-152448\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/pablogsal","@type":"Person","name":"pablogsal"},"datePublished":"2026-06-17T21:14:14Z","url":"https://github.com/python/cpython/issues/151613"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d5b9b239-71d6-6ea7-6d8b-0abeea6b633d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBD94:EAD6D:82224F:A34997:6B0222EA
html-safe-nonce43039bffe1db8c0619e181f9a3979ee34f1b494c93ca6faf3f73e7ae11d36db6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDk0OkVBRDZEOjgyMjI0RjpBMzQ5OTc6NkIwMjIyRUEiLCJ2aXNpdG9yX2lkIjoiNTk0MzI4MjgxOTA2NTUzNTc4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacccd122afdc036d694c9558a5510af98edf75f59a6edb08f0c82337a50fcfd2cf
hovercard-subject-tagissue:4687112824
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/python/cpython/151613/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a25b970c6b4b1b822441ec844854a0d16727586c7f50b15e15463621ce425675/python/cpython/issues/151613
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a25b970c6b4b1b822441ec844854a0d16727586c7f50b15e15463621ce425675/python/cpython/issues/151613
og:image:altThe remote debugging frame cache uses last_profiled_frame as an address anchor, so it can hit an ABA case when a frame address is reused after the old frame has returned. A profiler sample can then...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepablogsal
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
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
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/151613#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F151613
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F151613
Sign uphttps://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=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/151613
Reloadhttps://github.com/python/cpython/issues/151613
Reloadhttps://github.com/python/cpython/issues/151613
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/151613
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/151613
#151614https://github.com/python/cpython/pull/151614
_remote_debugging frame cache can reuse stale frame anchorshttps://github.com/python/cpython/issues/151613#top
#151614https://github.com/python/cpython/pull/151614
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
topic-profilinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-profiling%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/pablogsal
pablogsalhttps://github.com/pablogsal
on Jun 17, 2026https://github.com/python/cpython/issues/151613#issue-4687112824
#151437https://github.com/python/cpython/pull/151437
gh-151613: Fix remote debugging frame cache ABA #151614https://github.com/python/cpython/pull/151614
[3.15] gh-151613: Fix remote debugging frame cache ABA #152448https://github.com/python/cpython/pull/152448
pablogsalhttps://github.com/pablogsal
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
topic-profilinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-profiling%22
on Jun 17, 2026https://github.com/python/cpython/issues/151613#event-26882215762
StanFromIrelandhttps://github.com/StanFromIreland
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
on Jun 17, 2026https://github.com/python/cpython/issues/151613#event-26882251578
https://github.com/pablogsal
pablogsalhttps://github.com/pablogsal
on Jun 17, 2026https://github.com/python/cpython/issues/151613#issuecomment-4735625323
@maurycyhttps://github.com/maurycy
pablogsalhttps://github.com/pablogsal
on Jun 17, 2026https://github.com/python/cpython/issues/151613#event-26882455711
pythongh-151613: Fix remote debugging frame cache ABAhttps://github.com/pablogsal/cpython/commit/9f447d8566cd6f1c5d9f1fe39c670737800f06dc
pythongh-151613https://github.com/python/cpython/issues/151613
9f447d8https://github.com/pablogsal/cpython/commit/9f447d8566cd6f1c5d9f1fe39c670737800f06dc
pythongh-151613: Fix remote debugging frame cache ABAhttps://github.com/pablogsal/cpython/commit/418a947d0272c2431f5ebb34891b1a7dd69d70d8
pythongh-151613https://github.com/python/cpython/issues/151613
418a947https://github.com/pablogsal/cpython/commit/418a947d0272c2431f5ebb34891b1a7dd69d70d8
pythongh-151613: Fix remote debugging frame cache ABAhttps://github.com/pablogsal/cpython/commit/a548b240409779b5ee3bd71e02ba146854d5e703
pythongh-151613https://github.com/python/cpython/issues/151613
a548b24https://github.com/pablogsal/cpython/commit/a548b240409779b5ee3bd71e02ba146854d5e703
pythongh-151613: Fix remote debugging frame cache ABAhttps://github.com/pablogsal/cpython/commit/fc9fafd76992dd2f406243455293380d14044707
pythongh-151613https://github.com/python/cpython/issues/151613
fc9fafdhttps://github.com/pablogsal/cpython/commit/fc9fafd76992dd2f406243455293380d14044707
pablogsalhttps://github.com/pablogsal
on Jun 27, 2026https://github.com/python/cpython/issues/151613#event-27283475767
fixup! pythongh-151613: Fix remote debugging frame cache ABAhttps://github.com/pablogsal/cpython/commit/c179184e2f06b84759e14f215087aa8156d8c70d
pythongh-151613https://github.com/python/cpython/issues/151613
c179184https://github.com/pablogsal/cpython/commit/c179184e2f06b84759e14f215087aa8156d8c70d
pablogsalhttps://github.com/pablogsal
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#151614https://github.com/python/cpython/pull/151614
on Jun 27, 2026https://github.com/python/cpython/issues/151613#event-27284109669
pablogsalhttps://github.com/pablogsal
on Jun 27, 2026https://github.com/python/cpython/issues/151613#event-27284109670
gh-151613: Fix remote debugging frame cache ABA (#151614)https://github.com/python/cpython/commit/8cda6ae2f1f86f2d26c29586ffc9687b410abfcf
gh-151613https://github.com/python/cpython/issues/151613
#151614https://github.com/python/cpython/pull/151614
8cda6aehttps://github.com/python/cpython/commit/8cda6ae2f1f86f2d26c29586ffc9687b410abfcf
pythongh-151613: Fix remote debugging frame cache ABA (python#151614)https://github.com/pablogsal/cpython/commit/8b475e61a60c99760bb3ce5d4cde28a74d7a1e02
pythongh-151613https://github.com/python/cpython/issues/151613
python#151614https://github.com/python/cpython/pull/151614
8b475e6https://github.com/pablogsal/cpython/commit/8b475e61a60c99760bb3ce5d4cde28a74d7a1e02
[3.15] gh-151613: Fix remote debugging frame cache ABA (#152448)https://github.com/python/cpython/commit/65fbec64f6a4a6a8fb68f86e323efed54e5a083d
gh-151613https://github.com/python/cpython/issues/151613
#152448https://github.com/python/cpython/pull/152448
65fbec6https://github.com/python/cpython/commit/65fbec64f6a4a6a8fb68f86e323efed54e5a083d
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/151613
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/151613
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
topic-profilinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-profiling%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
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.