Title: test_sampling_with_collapsed_export fails when the profiler records an unreadable frame · Issue #160334 · python/cpython · GitHub
Open Graph Title: test_sampling_with_collapsed_export fails when the profiler records an unreadable frame · Issue #160334 · python/cpython
X Title: test_sampling_with_collapsed_export fails when the profiler records an unreadable frame · Issue #160334 · python/cpython
Description: Bug report Bug description: test_sampling_with_collapsed_export failed in the ASan job of my PR gh-160296 (the change there is in a multiprocessing test and is unrelated): FAIL: test_sampling_with_collapsed_export (test.test_profiling.te...
Open Graph Description: Bug report Bug description: test_sampling_with_collapsed_export failed in the ASan job of my PR gh-160296 (the change there is in a multiprocessing test and is unrelated): FAIL: test_sampling_with_...
X Description: Bug report Bug description: test_sampling_with_collapsed_export failed in the ASan job of my PR gh-160296 (the change there is in a multiprocessing test and is unrelated): FAIL: test_sampling_with_...
Opengraph URL: https://github.com/python/cpython/issues/160334
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test_sampling_with_collapsed_export fails when the profiler records an unreadable frame","articleBody":"# Bug report\n\n### Bug description:\n\n`test_sampling_with_collapsed_export` failed in the ASan job of my PR gh-160296 (the change there is in a multiprocessing test and is unrelated):\n\n```\nFAIL: test_sampling_with_collapsed_export (test.test_profiling.test_sampling_profiler.test_integration.TestSampleProfilerIntegration.test_sampling_with_collapsed_export)\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"/home/runner/work/cpython/cpython/Lib/test/test_profiling/test_sampling_profiler/test_integration.py\", line 512, in test_sampling_with_collapsed_export\n self.assertIn(\":\", part)\n ~~~~~~~~~~~~~^^^^^^^^^^^\nAssertionError: ':' not found in '\u003cunreadable frame>'\n```\n\nhttps://github.com/python/cpython/actions/runs/39832455069/job/120012213367\n\nSince gh-154194, `_remote_debugging` returns a degraded frame (file `\"~\"`, no location, function `\"\u003cunreadable frame>\"`) when it cannot read a code object, instead of failing the sample. `CollapsedStackCollector` turns the `None` location into line 0, and `export()` writes frames with file `\"~\"` and line 0 as just the function name, so the collapsed line contains `\u003cunreadable frame>` with no colon. The test expects every part to look like `file:func:line`, so it fails whenever a sample hits an unreadable frame. I have only seen it on the ASan build so far.\n\ngh-154195 updated `test_binary_format.py` for the new frame, but not this test.\n\nReproducer, without a target process:\n\n```python\nimport os\nimport tempfile\nfrom profiling.sampling.stack_collector import CollapsedStackCollector\n\ncollector = CollapsedStackCollector(1000)\n# The first (innermost) frame is what _remote_debugging returns\n# when it cannot read a code object (gh-154194).\nframes = [\n (\"~\", None, \"\u003cunreadable frame>\", None),\n (\"/tmp/script.py\", (10, 10, 0, 1), \"main\", None),\n]\ncollector.process_frames(frames, thread_id=1)\n\nfd, path = tempfile.mkstemp(suffix=\".txt\")\nos.close(fd)\ncollector.export(path)\nwith open(path) as f:\n line = f.read().strip()\nos.unlink(path)\n\nprint(line)\nstack_trace = line.rsplit(\" \", 1)[0]\nfor part in stack_trace.split(\";\"):\n print(repr(part), \":\" in part)\n```\n\nOutput:\n\n```\nCollapsed stack output written to /tmp/tmp....txt\ntid:1;script.py:main:10;\u003cunreadable frame> 1\n'tid:1' True\n'script.py:main:10' True\n'\u003cunreadable frame>' False\n```\n\n`\u003cGC>` frames (on by default in `sample()`) take the same `\"~\"` branch in `export()`, so they would fail this assertion too. The test could accept these special `\u003c...>` frames instead of requiring a colon. I can open a PR if that approach is fine.\n\nThe same test and the gh-154194 change are also in 3.15.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux, macOS\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-161515\n* gh-161686\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/devdavidejesus","@type":"Person","name":"devdavidejesus"},"datePublished":"2026-10-22T19:56:59Z","url":"https://github.com/python/cpython/issues/160334"}
| 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:7e9cfd93-c3d8-52cb-f45b-cce1c022cfb8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EBD2:2A98A:66243F:8090DB:6B021B39 |
| html-safe-nonce | 2cc08b3f3249c4b30adfcceaade33c439dc341fd08f268cc1c067ed46965ab3b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQkQyOjJBOThBOjY2MjQzRjo4MDkwREI6NkIwMjFCMzkiLCJ2aXNpdG9yX2lkIjoiMzUxMTMwMDI2MzUyMjczNjk1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 31bc708f85cd8d835953710288ebe4c58282f358f02c538e385838257da86f59 |
| hovercard-subject-tag | issue:5986475764 |
| 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/160334/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7b39a9f7c502607d3ca10eca86092ad9d5526655bbaef7d59436bc4aafb9c1df/python/cpython/issues/160334 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7b39a9f7c502607d3ca10eca86092ad9d5526655bbaef7d59436bc4aafb9c1df/python/cpython/issues/160334 |
| og:image:alt | Bug report Bug description: test_sampling_with_collapsed_export failed in the ASan job of my PR gh-160296 (the change there is in a multiprocessing test and is unrelated): FAIL: test_sampling_with_... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | devdavidejesus |
| 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