Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Assertion failure in instrumentation during interpreter finalization #110752

Closed
Labels
3.13bugs and security fixestype-bugAn unexpected behavior, bug, or error
@gaogaotiantian

Description

@gaogaotiantian

Bug report

Bug description:

importsysdeff(*args):passdefbar():yield42sys.settrace(f)g=bar()next(g)

The code above will trigger an assertion added in#109846.

python: Python/instrumentation.c:1576: _Py_Instrument: Assertion `(interp->ceval.eval_breaker & ~_PY_EVAL_EVENTS_MASK) == 0 || instrumentation_cross_checks(interp, code)' failed.Aborted

The reason is that during the interpreter finalization, the global event monitors are reset to 0. However, the garbage collection triggered a send to the generatorbar which then triggered_Py_Instrument.

is_version_up_to_date is true because the the code was instrumented when last timeeval_breaker changed. However,instrumentation_cross_checks would fail, becauseinterp->monitors is reset to0.

Notice that in the code example above, if the trace functionf returns itself rather thanNone, the assertion failure won't trigger because the generator would not be garbage collected - this might be an instrumentation bug that made the generator uncollectable (I've confirmed that_PyGen_Finalize andgen_close() never executed). However, I did not connect the dots so I don't know why that did not work.

I've made a simple patch in the PR, where I reset theinterp->ceval.eval_breaker = 0 ininterpreter_clear. It's kind of reasonable but I'm not knowledgeable enough to be confident that this is the/a correct fix.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp