Title: `_remote_debugging`: `write_sample` advances the timestamp before writing the sample · Issue #158550 · python/cpython · GitHub
Open Graph Title: `_remote_debugging`: `write_sample` advances the timestamp before writing the sample · Issue #158550 · python/cpython
X Title: `_remote_debugging`: `write_sample` advances the timestamp before writing the sample · Issue #158550 · python/cpython
Description: Bug report (found while thinking about how to address the code review from #157228) The timestamp is advanced before the stack is built: https://github.com/python/cpython/blob/b9546455ab0/Modules/_remote_debugging/binary_io_writer.c#L952...
Open Graph Description: Bug report (found while thinking about how to address the code review from #157228) The timestamp is advanced before the stack is built: https://github.com/python/cpython/blob/b9546455ab0/Modules/_...
X Description: Bug report (found while thinking about how to address the code review from #157228) The timestamp is advanced before the stack is built: https://github.com/python/cpython/blob/b9546455ab0/Modules/_...
Opengraph URL: https://github.com/python/cpython/issues/158550
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`_remote_debugging`: `write_sample` advances the timestamp before writing the sample","articleBody":"### Bug report\n\n(found while thinking about how to address the code review from https://github.com/python/cpython/pull/157228)\n\nThe timestamp is advanced before the stack is built:\n\nhttps://github.com/python/cpython/blob/b9546455ab0/Modules/_remote_debugging/binary_io_writer.c#L952-L953\n\nIf there's a failure, such as:\n\nhttps://github.com/python/cpython/blob/763b6edb0ec959bdfb78f098b76829365de36ca5/Lib/profiling/sampling/sample.py#L180-L184\n\nThen the timestamps for the thread is shifted. That's a hard corruption for a delta-based format.\n\n# Reproduction\n\n```bash\nmaurycy@gimel cpython-315 (main e580c88?) % cat repro.py\nimport _remote_debugging\n\nw = _remote_debugging.BinaryWriter(\"/tmp/o.bin\", 1000, 0)\ntry:\n w.write_sample([(0, [(1, 0, [(42, None, \"f\", None)])])], 5000)\nexcept TypeError:\n pass\nw.write_sample([(0, [(1, 0, [(\"a.py\", None, \"f\", None)])])], 6000)\nw.finalize()\n\nclass C:\n def collect(self, frames, timestamps_us=None, **kw):\n print(timestamps_us)\n\n_remote_debugging.BinaryReader(\"/tmp/o.bin\").replay(C())\nmaurycy@gimel cpython-315 (main e580c88?) % ./python.exe repro.py\n[1000]\n```\n\nAnother repro could involve `_testcapi.set_nomemory`, incorrect unicode etc.\n\n### CPython versions tested on:\n\nCPython main branch, 3.15\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-158551\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/maurycy","@type":"Person","name":"maurycy"},"datePublished":"2026-10-01T07:05:47Z","url":"https://github.com/python/cpython/issues/158550"}
| 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:51f0a091-a13d-e9ec-73b2-22b5fcc857f5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E5E8:33444D:3627744:47FAC0C:6B020982 |
| html-safe-nonce | 155c066e57688c38eda086f41fddf1dc9166a762a5afe828ca8376fec8dabda8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNUU4OjMzNDQ0RDozNjI3NzQ0OjQ3RkFDMEM6NkIwMjA5ODIiLCJ2aXNpdG9yX2lkIjoiNjM1MDQ1MTIxMzAxMTY1MDk0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | eefa9c521441a19a4e3cc369c4399878586b469bb1b492c1d50d1cb10ba2ea03 |
| hovercard-subject-tag | issue:5658350134 |
| 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/158550/issue_layout |
| twitter:image | https://opengraph.githubassets.com/90ae6b761e70d44baaf6c6f6684cff4c555147f976f4a874301db79c5ed9ab9c/python/cpython/issues/158550 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/90ae6b761e70d44baaf6c6f6684cff4c555147f976f4a874301db79c5ed9ab9c/python/cpython/issues/158550 |
| og:image:alt | Bug report (found while thinking about how to address the code review from #157228) The timestamp is advanced before the stack is built: https://github.com/python/cpython/blob/b9546455ab0/Modules/_... |
| 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