Skip to content

Conversation

@efimov-mikhail
Copy link
Member

@efimov-mikhail efimov-mikhail commented Nov 3, 2025

I've removed setting interp->jit to false at finalization.
Because in rare case it may be a problem when some optimized code is used after finalize_modules.

New test needs subprocess since we have assertion crash only at the finalization stage.
On release builds there was no real problem, and test passed with this fix and without it.

@Fidget-Spinner
Copy link
Member

Hmm I think this isn't the problem.

The problem might be that JUMP_BACKWARD is specialized to JUMP_BACKWARD_JIT.

Following that, finalization happens, turning the JIT off. However, some of the JUMP_BACKWARD still remains as JUMP_BACKWARD_JIT.

This causes optimizer to be triggered on JUMP_BACKWARD_JIT.

The real fix should be to check if interp->jit is false in _PyOptimizer_Optimize and immediately return if not.

@efimov-mikhail
Copy link
Member Author

CC @brandtbucher as author of #129194

@efimov-mikhail
Copy link
Member Author

The real fix should be to check if interp->jit is false in _PyOptimizer_Optimize and immediately return if not.

Ok, I've provided this fix.

@Fidget-Spinner
Copy link
Member

@efimov-mikhail thanks. Just checking: does it pass the test on your system? I didn't test it but I think it should.

@efimov-mikhail
Copy link
Member Author

On my system new test passes with this fix and fails without it on debug build.
And all others tests also pass.

Comment on lines 2686 to 2696
tmp = tempfile.NamedTemporaryFile(delete=False, suffix='.py')
tmp.write(code.encode('utf-8'))
tmp.close()
try:
p = subprocess.Popen([sys.executable, tmp.name], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
p.wait()
out = p.stdout.read()
finally:
os.remove(tmp.name)
p.stdout.close()
self.assertEqual(b"finished", out)
Copy link
Member

Choose a reason for hiding this comment

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

Why not just use assert_python_ok?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, thanks! Of course, we can use it here. I've provided this change.

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.

3 participants