Skip to content

code objects remove unknown opcodes from the instruction stream when accessing co_code #128045

Closed
@DinoV

Description

@DinoV

Bug report

Bug description:

If you construct a code object with an unknown opcode it'll get removed when the code object goes through the opcodes to de-opt them. We should just ignore unknown opcodes instead.

CPython versions tested on:

3.12, 3.14

Operating systems tested on:

Linux

Linked PRs

Activity

added
type-bugAn unexpected behavior, bug, or error
on Dec 17, 2024
added
interpreter-core(Objects, Python, Grammar, and Parser dirs)
3.12only security fixes
3.13bugs and security fixes
3.14bugs and security fixes
on Dec 17, 2024
markshannon

markshannon commented on Dec 20, 2024

@markshannon
Member

Constructing a code object with an unknown opcode seems like a bug to me.

I presume this is for Cinder.
Is there a way to make this work for Cinder, without making CPython less resilient?

DinoV

DinoV commented on Jan 29, 2025

@DinoV
ContributorAuthor

The problem here is that this is related to our extension of the interpreter loop, so the opcodes are known to us, but unknown to the code object. I suppose we could open these tables up and allow someone to say "these are known opcodes" but I'm not sure that's an improvement.

Also we're not doing anything like "reject code objects with unknown opcodes", instead they're just silently turning into 0's which doesn't seem like it's being very resilient in the first place.

added a commit that references this issue on May 19, 2025

gh-128045: Mark unknown opcodes as deopting to themselves (#128044)

cc9add6
added a commit that references this issue on May 19, 2025

pythongh-128045: Mark unknown opcodes as deopting to themselves (pyth…

added 2 commits that reference this issue on May 19, 2025

gh-128045: Syncs w/ latest opcode metadata (#134231)

3fa30d9

[3.14] gh-128045: Mark unknown opcodes as deopting to themselves (GH-…

c869898
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      code objects remove unknown opcodes from the instruction stream when accessing `co_code` · Issue #128045 · python/cpython

      Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

      Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant