René's URL Explorer Experiment


Title: Code objects have incorrect hash/equality when code is instrumented for sys.monitoring · Issue #111984 · python/cpython · GitHub

Open Graph Title: Code objects have incorrect hash/equality when code is instrumented for sys.monitoring · Issue #111984 · python/cpython

X Title: Code objects have incorrect hash/equality when code is instrumented for sys.monitoring · Issue #111984 · python/cpython

Description: Bug report Bug description: A thread stress test in the coverage.py test suite was failing with seemingly impossible behavior: a code object is used as a key in a dict, and then cannot be found. I eventually tracked it down to a mismatch...

Open Graph Description: Bug report Bug description: A thread stress test in the coverage.py test suite was failing with seemingly impossible behavior: a code object is used as a key in a dict, and then cannot be found. I ...

X Description: Bug report Bug description: A thread stress test in the coverage.py test suite was failing with seemingly impossible behavior: a code object is used as a key in a dict, and then cannot be found. I ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Code objects have incorrect hash/equality when code is instrumented for sys.monitoring","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nA thread stress test in the coverage.py test suite was failing with seemingly impossible behavior: a code object is used as a key in a dict, and then cannot be found.  I eventually tracked it down to a mismatch between how bytecodes are examined in code_hash and in code_richcompare.\r\n\r\nI have instructions for demonstrating the problem if you like, though it's a thread race condition, so it's a bit involved: https://gist.github.com/nedbat/2fb43527d102b8bb6e7fb7f3400fa3a9\r\n\r\n# Hash computation\r\n\r\nWhen computing the hash, opcodes are checked if they are instrumented, and if so, use the original opcodes:\r\n\r\n```c\r\nstatic Py_hash_t\r\ncode_hash(PyCodeObject *co)\r\n{\r\n    //...\r\n    for (int i = 0; i \u003c Py_SIZE(co); i++) {\r\n        int deop = _Py_GetBaseOpcode(co, i);\r\n        SCRAMBLE_IN(deop);\r\n        SCRAMBLE_IN(_PyCode_CODE(co)[i].op.arg);\r\n        i += _PyOpcode_Caches[deop];\r\n    }\r\n```\r\n\r\n```c\r\n/* Get the underlying opcode, stripping instrumentation */\r\nint _Py_GetBaseOpcode(PyCodeObject *code, int i)\r\n{\r\n    int opcode = _PyCode_CODE(code)[i].op.code;\r\n    if (opcode == INSTRUMENTED_LINE) {\r\n        opcode = code->_co_monitoring->lines[i].original_opcode;\r\n    }\r\n    if (opcode == INSTRUMENTED_INSTRUCTION) {\r\n        opcode = code->_co_monitoring->per_instruction_opcodes[i];\r\n    }\r\n    CHECK(opcode != INSTRUMENTED_INSTRUCTION);\r\n    CHECK(opcode != INSTRUMENTED_LINE);\r\n    int deinstrumented = DE_INSTRUMENT[opcode];\r\n    if (deinstrumented) {\r\n        return deinstrumented;\r\n    }\r\n    return _PyOpcode_Deopt[opcode];\r\n}\r\n```\r\n\r\n```\r\n#define _PyCode_CODE(CO) _Py_RVALUE((_Py_CODEUNIT *)(CO)->co_code_adaptive)\r\n```\r\n\r\n# Equality\r\n\r\nWhen checking equality, opcodes are not checked if they are instrumented:\r\n\r\n```\r\nstatic PyObject *\r\ncode_richcompare(PyObject *self, PyObject *other, int op)\r\n{\r\n    // ...\r\n    for (int i = 0; i \u003c Py_SIZE(co); i++) {\r\n        _Py_CODEUNIT co_instr = _PyCode_CODE(co)[i];\r\n        _Py_CODEUNIT cp_instr = _PyCode_CODE(cp)[i];\r\n        co_instr.op.code = _PyOpcode_Deopt[co_instr.op.code];\r\n        cp_instr.op.code = _PyOpcode_Deopt[cp_instr.op.code];\r\n        eq = co_instr.cache == cp_instr.cache;\r\n        if (!eq) {\r\n            goto unequal;\r\n        }\r\n        i += _PyOpcode_Caches[co_instr.op.code];\r\n    }\r\n```\r\n\r\nIt seems like the hash and the equality will be well matched if the code hasn't been instrumented. But if it has been, then they don't match.\r\n\r\n\r\n### CPython versions tested on:\r\n\r\n3.12\r\n\r\n### Operating systems tested on:\r\n\r\n_No response_","author":{"url":"https://github.com/nedbat","@type":"Person","name":"nedbat"},"datePublished":"2023-11-11T18:09:08Z","url":"https://github.com/python/cpython/issues/111984"}

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:92cb34d5-c8f7-c3ce-eca6-a16e579b5e7c
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id91AC:283776:100D2C9:15860C6:6B005C97
html-safe-nonce6fb9e3917ee380e57e56e8f5dc545542993cf6cabcfe551997590a0ec7eb0df6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MUFDOjI4Mzc3NjoxMDBEMkM5OjE1ODYwQzY6NkIwMDVDOTciLCJ2aXNpdG9yX2lkIjoiMTcwMTAwNjQ0MDU3MjkzNTMxOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaca8a68a8fd378f56c544c9d3a49606d3f5ab9fd899410d68db334985b523fbe16
hovercard-subject-tagissue:1989064764
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/111984/issue_layout
twitter:imagehttps://opengraph.githubassets.com/bf41b536b00036e1dd33605eb2512e066fb05e3263a41351c8d3629858880e34/python/cpython/issues/111984
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/bf41b536b00036e1dd33605eb2512e066fb05e3263a41351c8d3629858880e34/python/cpython/issues/111984
og:image:altBug report Bug description: A thread stress test in the coverage.py test suite was failing with seemingly impossible behavior: a code object is used as a key in a dict, and then cannot be found. I ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamenedbat
hostnamegithub.com
expected-hostnamegithub.com
None29be975efff6507a5d135de9c7d634cf7ff8f0c55222a64386ab3202209aaf73
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
releaseeacd927ba6112e3b01ba99c762bd699a4a4f5df7
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/111984#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F111984
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%2F111984
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/111984
Reloadhttps://github.com/python/cpython/issues/111984
Reloadhttps://github.com/python/cpython/issues/111984
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/111984
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/111984
Code objects have incorrect hash/equality when code is instrumented for sys.monitoringhttps://github.com/python/cpython/issues/111984#top
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/nedbat
nedbathttps://github.com/nedbat
on Nov 11, 2023https://github.com/python/cpython/issues/111984#issue-1989064764
https://gist.github.com/nedbat/2fb43527d102b8bb6e7fb7f3400fa3a9https://gist.github.com/nedbat/2fb43527d102b8bb6e7fb7f3400fa3a9
nedbathttps://github.com/nedbat
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Nov 11, 2023https://github.com/python/cpython/issues/111984#event-10932911844
gpsheadhttps://github.com/gpshead
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%22
on Nov 11, 2023https://github.com/python/cpython/issues/111984#event-10932939861
https://github.com/gaogaotiantian
gaogaotiantianhttps://github.com/gaogaotiantian
on Nov 11, 2023https://github.com/python/cpython/issues/111984#issuecomment-1806888947
#109107https://github.com/python/cpython/pull/109107
@brandtbucherhttps://github.com/brandtbucher
https://github.com/nedbat
nedbathttps://github.com/nedbat
on Nov 11, 2023https://github.com/python/cpython/issues/111984#issuecomment-1806896181
https://github.com/brandtbucher
brandtbucherhttps://github.com/brandtbucher
on Nov 22, 2023https://github.com/python/cpython/issues/111984#issuecomment-1823514783
@gaogaotiantianhttps://github.com/gaogaotiantian
https://github.com/gaogaotiantian
gaogaotiantianhttps://github.com/gaogaotiantian
on Nov 23, 2023https://github.com/python/cpython/issues/111984#issuecomment-1823845615
#112329https://github.com/python/cpython/pull/112329
brandtbucherhttps://github.com/brandtbucher
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 23, 2023https://github.com/python/cpython/issues/111984#event-11050213586
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/111984
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/111984
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%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.