Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Instrumentation assertion failure when calling the registered handler explicitly #122247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pschanely opened this issue Jul 24, 2024 · 1 comment
Assignees
Labels
type-bug An unexpected behavior, bug, or error

Comments

@pschanely
Copy link
Contributor

pschanely commented Jul 24, 2024

Bug report

Bug description:

On my mac M1 Sonoma (14.5), Python 3.13.0b4, I see this crash when registering an opcode monitor, calling the handler explicitly while it's enabled, and then restarting events. To reproduce:

import sys

def mymonitor(code, instruction_offset):
    pass

tool_id = 4
sys.monitoring.use_tool_id(tool_id, "mytool")
sys.monitoring.register_callback(
    tool_id,
    sys.monitoring.events.INSTRUCTION,
    mymonitor,
)
sys.monitoring.set_events(tool_id, sys.monitoring.events.INSTRUCTION)
mymonitor(None, 0)  # call the *same* handler while it is registered                                                                                                                                                                                                                       
sys.monitoring.restart_events()

Triggers an assertion failure (my minimal debugging suggests it's about some inconsistency with the "instrumentation_version"):

$ 3.13.0b4-debug/bin/python -X dev repro.py
Assertion failed: (debug_check_sanity(tstate->interp, code)), function _Py_call_instrumentation_instruction, file instrumentation.c, line 1347.
Fatal Python error: Aborted

Current thread 0x00000002064b0c00 (most recent call first):
  File "/Users/phillipschanely/proj/CrossHair/repro.py", line 4 in mymonitor
  File "/Users/phillipschanely/proj/CrossHair/repro.py", line 16 in <module>
zsh: abort      /Users/phillipschanely/.pyenv/versions/3.13.0b4-debug/bin/python -X dev 

Thanks for investigating!

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Linked PRs

@pschanely pschanely added the type-bug An unexpected behavior, bug, or error label Jul 24, 2024
@gaogaotiantian gaogaotiantian self-assigned this Jul 24, 2024
@gaogaotiantian
Copy link
Member

Confirmed on main. I'll take a look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants