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

Appearance settings

bpo-46465: Check eval breaker in specialized CALL opcodes#30826

Closed
Fidget-Spinner wants to merge 4 commits intopython:mainpython/cpython:mainfrom
Fidget-Spinner:call_check_eval_breakerFidget-Spinner/cpython:call_check_eval_breakerCopy head branch name to clipboard
Closed

bpo-46465: Check eval breaker in specialized CALL opcodes#30826
Fidget-Spinner wants to merge 4 commits intopython:mainpython/cpython:mainfrom
Fidget-Spinner:call_check_eval_breakerFidget-Spinner/cpython:call_check_eval_breakerCopy head branch name to clipboard

Conversation

@Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Jan 23, 2022

@Fidget-Spinner
Copy link
Member Author

I added CHECK_EVAL_BREAKER to all CALL_X opcodes, but I'm not sure how to do that for CALL_NO_KW_PY_SIMPLE (and the inline Python call path of CALL_NO_KW). @pablogsal and @markshannon can I please get your opinion on whether we need to check for signals for those?

Lib/test/support/__init__.py Outdated Show resolved Hide resolved
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the "error" label ends with DISPATCH(). It doesn't call CHECK_EVAL_BREAKER() even if we are coming from a CALL target which can get a signal (or any other reason to break the ceval).

I'm not sure that I like the test decorator, it makes a test 16x slower :-(

Lib/test/support/__init__.py Outdated Show resolved Hide resolved
Lib/test/support/__init__.py Outdated Show resolved Hide resolved
Lib/test/support/__init__.py Outdated Show resolved Hide resolved
Lib/test/support/__init__.py Outdated Show resolved Hide resolved
Lib/test/support/__init__.py Outdated Show resolved Hide resolved
Lib/unittest/test/test_break.py Outdated Show resolved Hide resolved
@vstinner
Copy link
Member

Currently, the "error" label ends with DISPATCH(). It doesn't call CHECK_EVAL_BREAKER() even if we are coming from a CALL target which can get a signal (or any other reason to break the ceval).

In Python 3.10, the error label ends with "goto main_loop" which does check for the ceval breaker atomic variable, no?

@vstinner
Copy link
Member

I added CHECK_EVAL_BREAKER to all CALL_X opcodes, but I'm not sure how to do that for CALL_NO_KW_PY_SIMPLE (and the inline Python call path of CALL_NO_KW). @pablogsal and @markshannon can I please get your opinion on whether we need to check for signals for those?

CALL_NO_KW_PY_SIMPLE optimization goes to start_frame which ends with DISPATCH(): it seems like the CHECK_EVAL_BREAKER() check has been eaten by the optimization, between Python 3.10 and 3.11. Either start_frame or start_frame should call CHECK_EVAL_BREAKER().

@vstinner
Copy link
Member

The ceval.c change are enough for almost all TARGET, except CALL_NO_KW_PY_SIMPLE which miss CHECK_EVAL_BREAKER() somewhere, but it can be fixed in a separated PR (with a fix for "error" label ? ;-)) if you prefer.

Co-Authored-By: Victor Stinner <vstinner@python.org>
@Fidget-Spinner
Copy link
Member Author

The ceval.c change are enough for almost all TARGET, except CALL_NO_KW_PY_SIMPLE which miss CHECK_EVAL_BREAKER() somewhere, but it can be fixed in a separated PR (with a fix for "error" label ? ;-)) if you prefer.

Yeah I'd prefer another PR for that. I don't think those changes came with the CALL_X PR, maybe one of the refactoring/dispatch optimizing PRs.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Python/ceval.c Outdated Show resolved Hide resolved
Python/ceval.c Outdated Show resolved Hide resolved
Python/ceval.c Outdated Show resolved Hide resolved
Lib/test/support/__init__.py Outdated Show resolved Hide resolved
Co-Authored-By: Mark Shannon <mark@hotpy.org>
@Fidget-Spinner
Copy link
Member Author

Fidget-Spinner commented Jan 24, 2022

Strange, Ubuntu tests fail even on non-specialized code.

testInstallHandler (unittest.test.test_break.TestBreak) ... 
  testInstallHandler (unittest.test.test_break.TestBreak) (cpython_is_warmedup=False) ... FAIL
  testInstallHandler (unittest.test.test_break.TestBreak) (cpython_is_warmedup=False) ... FAIL
  testInstallHandler (unittest.test.test_break.TestBreak) (cpython_is_warmedup=False) ... FAIL
  testInstallHandler (unittest.test.test_break.TestBreak) (cpython_is_warmedup=False) ... FAIL
  testInstallHandler (unittest.test.test_break.TestBreak) (cpython_is_warmedup=False) ... FAIL
  testInstallHandler (unittest.test.test_break.TestBreak) (cpython_is_warmedup=False) ... FAIL
  testInstallHandler (unittest.test.test_break.TestBreak) (cpython_is_warmedup=False) ... FAIL
  testInstallHandler (unittest.test.test_break.TestBreak) (cpython_is_warmedup=True) ... FAIL

======================================================================
FAIL: testInstallHandler (unittest.test.test_break.TestBreak) (cpython_is_warmedup=False)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/support/__init__.py", line 2142, in wrapper
    f(self)
    ^^^^^^^
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/unittest/test/test_break.py", line 33, in testInstallHandler
    self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: <unittest.signals._InterruptHandler object at 0x7f7f10afb760> == <unittest.signals._InterruptHandler object at 0x7f7f10afb760>

I'll look into it.


# Tests both adaptive and specialized opcodes for proper
# CHECK_EVAL_BREAKER(). See bpo-46465 for an example bug.
@repeat_cpython_adaptative
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I've tested in https://bugs.python.org/issue46709 there several more test cases that require this decorator:

  • testInterruptCaught
  • testSecondInterrupt
  • testTwoResults

@Fidget-Spinner
Copy link
Member Author

Sorry, can I trouble someone here to take over this PR please? I can't complete it right now.

@sobolevn
Copy link
Member

@Fidget-Spinner I will cover your back 😉

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.