Title: Zero-width characters cause unbounded memory use in PyREPL · Issue #126685 · python/cpython · GitHub
Open Graph Title: Zero-width characters cause unbounded memory use in PyREPL · Issue #126685 · python/cpython
X Title: Zero-width characters cause unbounded memory use in PyREPL · Issue #126685 · python/cpython
Description: Bug report Bug description: Trying to paste zero-width characters (U+200B, U+200C, U+200D, U+FEFF) into the new REPL causes it to get stuck and keep allocating memory. Python 3.12 handles them fine. This seems to happen during screen cal...
Open Graph Description: Bug report Bug description: Trying to paste zero-width characters (U+200B, U+200C, U+200D, U+FEFF) into the new REPL causes it to get stuck and keep allocating memory. Python 3.12 handles them fine...
X Description: Bug report Bug description: Trying to paste zero-width characters (U+200B, U+200C, U+200D, U+FEFF) into the new REPL causes it to get stuck and keep allocating memory. Python 3.12 handles them fine...
Opengraph URL: https://github.com/python/cpython/issues/126685
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Zero-width characters cause unbounded memory use in PyREPL","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nTrying to paste zero-width characters (`U+200B`, `U+200C`, `U+200D`, `U+FEFF`) into the new REPL causes it to get stuck and keep allocating memory. Python 3.12 handles them fine.\r\n\r\nThis seems to happen during screen calculation, so the amount of characters needed to reproduce will depend on the number of cells in a terminal emulator window (I got it working with as few as 3 with a big enough zoom, but 100 should be enough).\r\n\r\nA table with all of them x100 to copy for convenience:\r\n\r\nZWSP | ZWNJ | ZWJ | ZWNBSP\r\n--- | --- | --- | ---\r\n`` | `` | `` | ``\r\n\r\n### To reproduce\r\n1. Open the new REPL\r\n2. Paste in some zero-width characters\r\n3. The REPL should get stuck and keep allocating memory\r\n4. Can be stopped with double `^C` or a single `^\\`\r\n\r\nThe culprit seems to be this loop in `Lib/_pyrepl/reader.py:Reader.calc_screen` and its `screen`/`screen_info` appends:\r\nhttps://github.com/python/cpython/blob/f4e5643df64d0c2a009ed224560044b3409a47c0/Lib/_pyrepl/reader.py#L388-L411\r\n\r\n### An additional demo\r\n\r\nhttps://github.com/user-attachments/assets/0060044b-fee1-49c4-a273-006dff1b67e9\r\n\r\n### CPython versions tested on:\r\n\r\n3.12, 3.13, CPython main branch\r\n\r\n### Operating systems tested on:\r\n\r\nLinux, macOS","author":{"url":"https://github.com/trag1c","@type":"Person","name":"trag1c"},"datePublished":"2024-11-11T13:56:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/126685/cpython/issues/126685"}
| 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:037de965-f707-ea9a-ef92-61abd3aa82f3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B510:FC316:14C19C9:1B94768:696ADD53 |
| html-safe-nonce | 9da75a83d1a106d3e77358cd1bd8cb2dc05208c77f8bc04b0d76ab2553c33ed7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTEwOkZDMzE2OjE0QzE5Qzk6MUI5NDc2ODo2OTZBREQ1MyIsInZpc2l0b3JfaWQiOiI4NTAyODQwNDgyNDM2MTQ0NDY3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f1536e40241beb04d2752df501e8070ddaca0500bf0e6a5ff05a77cff4001da4 |
| hovercard-subject-tag | issue:2649420493 |
| 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/126685/issue_layout |
| twitter:image | https://opengraph.githubassets.com/46ed3acdecb922a5e4456ef36445e7b417a7ae34bfa8251df36a11eb075211f7/python/cpython/issues/126685 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/46ed3acdecb922a5e4456ef36445e7b417a7ae34bfa8251df36a11eb075211f7/python/cpython/issues/126685 |
| og:image:alt | Bug report Bug description: Trying to paste zero-width characters (U+200B, U+200C, U+200D, U+FEFF) into the new REPL causes it to get stuck and keep allocating memory. Python 3.12 handles them fine... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | trag1c |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 524a93f2c1f36522a3b4be4c110467ee4172245d |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width