Skip to content

Assertion Failure: Deepfrozen code object gets re-quickened #92031

@sweeneyde

Description

@sweeneyde

A third bug found while working on #91713 🙃

Bug report

I can reproduce this locally on my Windows machine:

.\python.bat -m test test_embed -m test_finalize_structseq -R1:50 

This is the result:

PS C:\Users\sween\Source\Repos\cpython2\cpython> .\python.bat -m test test_embed -m test_finalize_structseq -R1:50 Running Debug|x64 interpreter... WARNING: Running tests with --huntrleaks/-R and less than 3 warmup repetitions can give false positives! 0:00:00 Run tests sequentially 0:00:00 [1/1] test_embed beginning 51 repetitions 123456789012345678901234567890123456789012345678901 ...................test test_embed failed -- Traceback (most recent call last): File "C:\Users\sween\Source\Repos\cpython2\cpython\Lib\test\test_embed.py", line 343, in test_finalize_structseq out, err = self.run_embedded_interpreter("test_repeated_init_exec", code) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\sween\Source\Repos\cpython2\cpython\Lib\test\test_embed.py", line 117, in run_embedded_interpreter self.assertEqual(p.returncode, returncode, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: 3 != 0 : bad returncode 3, stderr is '--- Loop #1 ---\n..\n----------------------------------------------------------------------\nRan 2 tests in 0.001s\n\nOK\n--- Loop #2 ---\nA\x00s\x00s\x00e\x00r\x00t\x00i\x00o\x00n\x00 \x00f\x00a\x00i\x00l\x00e\x00d\x00:\x00 \x00i\x00n\x00s\x00t\x00r\x00u\x00c\x00t\x00i\x00o\x00n\x00s\x00[\x00i\x00 \x00+\x00 \x001\x00]\x00 \x00=\x00=\x00 \x000\x00,\x00 \x00f\x00i\x00l\x00e\x00 \x00C\x00:\x00\\\x00U\x00s\x00e\x00r\x00s\x00\\\x00s\x00w\x00e\x00e\x00n\x00\\\x00S\x00o\x00u\x00r\x00c\x00e\x00\\\x00R\x00e\x00p\x00o\x00s\x00\\\x00c\x00p\x00y\x00t\x00h\x00o\x00n\x002\x00\\\x00c\x00p\x00y\x00t\x00h\x00o\x00n\x00\\\x00P\x00y\x00t\x00h\x00o\x00n\x00\\\x00s\x00p\x00e\x00c\x00i\x00a\x00l\x00i\x00z\x00e\x00.\x00c\x00,\x00 \x00l\x00i\x00n\x00e\x00 \x002\x006\x006\x00\n\x00' test_embed failed (1 failure) == Tests result: FAILURE == 1 test failed: test_embed Total duration: 17.7 sec Tests result: FAILURE 

A more self-contained simplified (less unittest) reproducer is this:

from test import support import os import os.path import subprocess import sys MS_WINDOWS = (os.name == 'nt') MACOS = (sys.platform == 'darwin') def debug_build(program): program = os.path.basename(program) name = os.path.splitext(program)[0] return name.casefold().endswith("_d".casefold()) exename = "_testembed" builddir = os.path.dirname(sys.executable) if MS_WINDOWS: ext = ("_d" if debug_build(sys.executable) else "") + ".exe" exename += ext exepath = builddir expecteddir = os.path.join(support.REPO_ROOT, builddir) else: exepath = os.path.join(builddir, 'Programs') expecteddir = os.path.join(support.REPO_ROOT, 'Programs') test_exe = os.path.join(exepath, exename) ########################################################### os.chdir(support.REPO_ROOT) code = """if 1:  import unittest  print("Tests passed") """ cmd = [test_exe, "test_repeated_init_exec", code] for i in range(200): print(i) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, env=None, cwd=None) (out, err) = p.communicate(input=input, timeout=None) print(out) if p.returncode != 0: print("bad return code", p.returncode) print(err) break

This fails with the following message:

A s s e r t i o n f a i l e d : i n s t r u c t i o n s [ i + 1 ] = = 0 , f i l e C : \ U s e r s \ s w e e n \ S o u r c e \ R e p o s \ c p y t h o n 2 \ c p y t h o n \ P y t h o n \ s p e c i a l i z e . c , l i n e 2 6 6 

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions