GeezerVison is showing github.com — `test_capi.test_opt.test_call_len_known_length` fails on JIT+debug builds · Issue #139393 · python/cpython
test_capi.test_opt.test_call_len_known_length fails on JIT+debug builds #139393
Labels 3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)testsTests in the Lib/test dirTests in the Lib/test dirtopic-C-APItopic-JITtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug report
Bug description:
Bug Description
The test_capi test suite fails when CPython is built from the main branch with debug, optimizations (PGO), LTO, and the experimental JIT enabled.
Steps to Reproduce
- Clone the cpython repository.
- Configure the build with the following flags:
./configure --with-pydebug --enable-optimizations --with-lto --enable-experimental-jit
- Build and run tests:
sudo make -j"$(nproc)" test
Expected Behavior
All tests should pass.
Actual Behavior
The test run fails with one failed test: test_capi.
The specific failing test is test_call_len_known_length within test.test_capi.test_opt.TestUopsOptimization.
Test Output
sudo_make_j_nproc_test.txt
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Activitychanged the title [-]test_capi fails on debug build with JIT, LTO and PGO[/-] [+]`test_capi.test_opt.test_call_len_known_length` fails on JIT LTO+PGO debug builds[/+] on Sep 28, 2025picnixz commented on Sep 28, 2025 Does it actually fail with just JIT + debug? or does it fail for JIT+LTO+PGO+debug (or maybe just LTO+PGO+debug) in particular? Stated otherwise, which feature is necessary for the test to fail? ashm-dev commented on Sep 28, 2025 ContributorAuthor More actions @picnixz I've completed testing with all requested configurations. Here is the summary of the results:
-
--with-pydebug --enable-optimizations --with-lto --enable-experimental-jit
(debug + LTO + PGO + JIT)
-
--with-pydebug --enable-experimental-jit
(debug + JIT)
- Result:
test_capi passes, but test_gdb fails.
-
--with-pydebug --enable-optimizations --with-lto
(debug + LTO + PGO)
- Result: All tests pass successfully.
This confirms that the test_capi failure is specifically triggered by the combination of the experimental JIT and the optimizations (--enable-optimizations --with-lto).
Neither JIT alone nor the optimizations alone (in a debug build) cause test_capi to fail.
Logs:
pydebug_pgo_lto_sudo_make_j_nproc_test.txt
pydebug_jit_sudo_make_j_nproc_test.txt picnixz commented on Sep 28, 2025 Thank you. I don't think LTO would be responsible for that, but can you also check debug+JIT+PGO? ashm-dev commented on Sep 28, 2025 ContributorAuthor More actions You were right! I've run the build with debug+JIT+PGO (by using ./configure --with-pydebug --enable-optimizations --enable-experimental-jit), and the test fails in the exact same way.
pydebug_jit_pgo_sudo_make_j_nproc_test.txt ashm-dev commented on Sep 28, 2025 ContributorAuthor More actions @picnixz I did additional testing with the debug+ LTO+JIT configuration (without PGO) to verify your assumption that LTO is not the cause.
Results for ./configure --with-pydebug --with-lto --enable-experimental-jit:
test_capi also crashes with the same AssertionError error: '_CALL_LEN' not found.
- In addition, the
test_gdb tests also crash in this build (test.test_gdb.test_backtrace, test.test_gdb.test_misc, test.test_gdb.test_pretty_print).
This clarifies the overall picture. It seems that your assumption that only PGO is the problem was not entirely correct. The error in test_capi is reproduced when combining JIT with any of the advanced optimizations (LTO or PGO).
pydebug_jit_lto_sudo_make_j_nproc_test.txt picnixz commented on Sep 28, 2025 Disclaimer: I'm using clang-18 for the JIT instead of clang-19 so some attributes are not valid but it shouldn't change much I guess.
I think I know the cause. The test assumes that the length is >= _PY_NSMALLPOSINTS. But we recently updated _PY_NSMALLPOSINTS to be 1025 instead of 256 (in 7ce25ed). To be precise, I think we hit the following check:
PyObject *temp = PyLong_FromSsize_t(tuple_length);
if (temp == NULL) {
goto error;
}
if (_Py_IsImmortal(temp)) {
REPLACE_OP(this_instr, _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW,
0, (uintptr_t)temp);
}
For a small tuple length, we update the instruction. However, I can confirm that debug + JIT (no optimizations) also trigger the issue with clang-18. Can you verify once again that you have a clean build? ashm-dev commented on Sep 28, 2025 ContributorAuthor More actions I understand you!
All my previous launches were on the default gcc from ubuntu
I decided to check how the tests will behave on clang, and yes, my results are the same as yours, jit+pgo and jit are falling due to capi, and the rest are going fine.
Versions:
gcc
➜ cpython gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 12.4.0-5ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-12-eQp2fa/gcc-12-12.4.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-eQp2fa/gcc-12-12.4.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.4.0 (Ubuntu 12.4.0-5ubuntu1)
clang
➜ cpython clang -v
Ubuntu clang version 20.1.2 (0ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-20/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/14
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/14
Candidate multilib: .;@m64
Selected multilib: .;@m64
Clang test logs:
clang_pydebug_jit_lto_pgo_sudo_make_j_nproc_test.txt
clang_pydebug_jit_lto_sudo_make_j_nproc_test.txt
clang_pydebug_jit_pgo_sudo_make_j_nproc_test.txt
clang_pydebug_jit_sudo_make_j_nproc_test.txt
clang_pydebug_lto_pgo_sudo_make_j_nproc_test.txt changed the title [-]`test_capi.test_opt.test_call_len_known_length` fails on JIT LTO+PGO debug builds[/-] [+]`test_capi.test_opt.test_call_len_known_length` fails on JIT builds[/+] on Sep 28, 2025changed the title [-]`test_capi.test_opt.test_call_len_known_length` fails on JIT builds[/-] [+]`test_capi.test_opt.test_call_len_known_length` fails on JIT+debug builds[/+] on Sep 28, 2025picnixz commented on Sep 28, 2025
MetadataMetadata3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)testsTests in the Lib/test dirTests in the Lib/test dirtopic-C-APItopic-JITtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DevelopmentNo branches or pull requestsIssue actions
|