Title: [3.12] Crash of repeated `Programs/_testembed.c` on Windows DEBUG build · Issue #128833 · python/cpython · GitHub
Open Graph Title: [3.12] Crash of repeated `Programs/_testembed.c` on Windows DEBUG build · Issue #128833 · python/cpython
X Title: [3.12] Crash of repeated `Programs/_testembed.c` on Windows DEBUG build · Issue #128833 · python/cpython
Description: Bug report Bug description: This is an issue that only affects Windows DEBUG builds and Python 3.12. I discovered it while writing #127780 and @Yhg1s (#127780 (comment)) investigated it more in details. The reproducer is as follows: PS D...
Open Graph Description: Bug report Bug description: This is an issue that only affects Windows DEBUG builds and Python 3.12. I discovered it while writing #127780 and @Yhg1s (#127780 (comment)) investigated it more in det...
X Description: Bug report Bug description: This is an issue that only affects Windows DEBUG builds and Python 3.12. I discovered it while writing #127780 and @Yhg1s (#127780 (comment)) investigated it more in det...
Opengraph URL: https://github.com/python/cpython/issues/128833
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[3.12] Crash of repeated `Programs/_testembed.c` on Windows DEBUG build","articleBody":"# Bug report\n\n### Bug description:\n\nThis is an issue that only affects Windows DEBUG builds and Python 3.12. I discovered it while writing #127780 and @Yhg1s (https://github.com/python/cpython/issues/127780#issuecomment-2590110764) investigated it more in details.\n\nThe reproducer is as follows:\n\n```powershell\nPS D:\\Python\\cpython\u003e D:\\\\Python\\\\cpython\\\\PCbuild\\\\amd64\\\\_testembed_d.exe test_repeated_init_exec 'import dis\n\u003e\u003e import importlib._bootstrap\n\u003e\u003e import opcode\n\u003e\u003e import test.test_dis\n\u003e\u003e\n\u003e\u003e def is_specialized(f):\n\u003e\u003e for instruction in dis.get_instructions(f, adaptive=True):\n\u003e\u003e opname = instruction.opname\n\u003e\u003e if (\n\u003e\u003e opname in opcode._specialized_instructions\n\u003e\u003e # Exclude superinstructions:\n\u003e\u003e and \\\"__\\\" not in opname\n\u003e\u003e ):\n\u003e\u003e return True\n\u003e\u003e return False\n\u003e\u003e\n\u003e\u003e func = importlib._bootstrap._handle_fromlist\n\u003e\u003e\n\u003e\u003e # \"copy\" the code to un-specialize it:\n\u003e\u003e func.__code__ = func.__code__.replace()\n\u003e\u003e\n\u003e\u003e assert not is_specialized(func), \\\"specialized instructions found\\\"\n\u003e\u003e\n\u003e\u003e for i in range(test.test_dis.ADAPTIVE_WARMUP_DELAY):\n\u003e\u003e func(importlib._bootstrap, [\\\"x\\\"], lambda *args: None)\n\u003e\u003e\n\u003e\u003e assert is_specialized(func), \\\"no specialized instructions found\\\"\n\u003e\u003e\n\u003e\u003e print(\\\"Tests passed\\\")'\n--- Loop #1 ---\nTests passed\n--- Loop #2 ---\nAssertion failed: PyUnicode_CheckExact(ep-\u003eme_key), file D:\\Python\\cpython\\Objects\\dictobject.c, line 939\n```\n\nParaphrasing Thomas, the assertion failure happens only the *second* time, namely after finalizing and reinitializing, and the `ep` the assertion fails on is a deallocated object. We suspect that something isn't refcounted correctly, isn't marked as immortal when it should be, or isn't recreated on interpreter starutp when it should be. However, we don't why the issue does not appear on Linux.\n\nAccording to Thomas, this is likely an issue with repeated calls to `Py_Finalize` and `Py_Initialize`. However, since 3.12 and 3.13 manage objects lifetime quite differently, it might be easier to just patch the test currently failing as follows: https://github.com/python/cpython/commit/68a33f3c6687698969ff5ea45dadf291a156f49f. \n\n### CPython versions tested on:\n\n3.12\n\n### Operating systems tested on:\n\nWindows, Linux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-128860\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/picnixz","@type":"Person","name":"picnixz"},"datePublished":"2025-01-14T15:12:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/128833/cpython/issues/128833"}
| 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:ac3c0e9e-a091-ce35-17ca-4a5768567499 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD28:14FC13:2148F5D:2BF1992:696B0E1F |
| html-safe-nonce | c570ac05e633f909c38f633f87d278152a00674d88a43afff96d19220f08e2b3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDI4OjE0RkMxMzoyMTQ4RjVEOjJCRjE5OTI6Njk2QjBFMUYiLCJ2aXNpdG9yX2lkIjoiNTIzMDI0MjcwOTA0MDIwNTM0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d076e61a4dd073de2624a06d348562bacd8ac5e84710375e1ad4458bb65c7570 |
| hovercard-subject-tag | issue:2787444947 |
| 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/128833/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9d61ea21619b610d205f04e0d4e0dc45b7b2b92a8933a68d43c4c99dc0dfd009/python/cpython/issues/128833 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9d61ea21619b610d205f04e0d4e0dc45b7b2b92a8933a68d43c4c99dc0dfd009/python/cpython/issues/128833 |
| og:image:alt | Bug report Bug description: This is an issue that only affects Windows DEBUG builds and Python 3.12. I discovered it while writing #127780 and @Yhg1s (#127780 (comment)) investigated it more in det... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | picnixz |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width