Skip to content

Stack overflow error from recursion with 3.14.0rc2 on linux #138215

@bellatoris

Description

@bellatoris

Crash report

What happened?

Crash report

What happened?

Building CPython 3.14.0rc2 with GCC 14 in a Linux environment crashes during PGO “profile-gen” while freezing stdlib modules — but only when configured with --with-tail-call-interp. The bootstrap interpreter runs Programs/_freeze_module.py and aborts with a RecursionError: Stack overflow, failing targets like Python/frozen_modules/os.h and _collections_abc.h. Without the tail-call interpreter enabled, this symptom did not appear in my environment.

Reproducer (focus on tail-call interpreter build)

# Toolchain: GCC 14.x on Linux (x86_64), ubuntu 24.04
# CPython: 3.14.0rc2 tarball

./configure \
    --build="$gnuArch" \
    --enable-loadable-sqlite-extensions \
    --enable-optimizations \
    --enable-option-checking=fatal \
    --enable-shared \
    --with-tail-call-interp \
    '--with-lto=full' \
    --with-ensurepip

make -j$(nproc)
# Fails during profile-gen while freezing modules

Observed output (truncated)

./_bootstrap_python ./Programs/_freeze_module.py frozen_only ./Tools/freeze/flag.py Python/frozen_modules/frozen_only.h
Traceback (most recent call last):
  File "/usr/src/python/./Programs/_freeze_module.py", line 51, in write_frozen
    write_code(outfile, marshalled, arrayname)
  File "/usr/src/python/./Programs/_freeze_module.py", line 41, in write_code
    outfile.write(",".join(str(i) for i in marshalled[n : n + 16]))
RecursionError: Stack overflow (used 8161 kB) while calling a Python object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/python/./Programs/_freeze_module.py", line 68, in <module>
    main()
  File "/usr/src/python/./Programs/_freeze_module.py", line 64, in main
    write_frozen(outpath, inpath, name, marshalled)
  File "/usr/src/python/./Programs/_freeze_module.py", line 47, in write_frozen
    with open(outpath, "w") as outfile:
RecursionError: Stack overflow (used 8162 kB) while calling a Python object
make[2]: *** [Makefile:1951: Python/frozen_modules/os.h] Error 1
make[2]: *** [Makefile:1936: Python/frozen_modules/_collections_abc.h] Error 1
make[1]: *** [Makefile:993: profile-gen-stamp] Error 2

Local environment & toolchain

• Platform: Linux (x86_64)
• Compiler: GCC 14.x
• Configure flags: as above, notably --with-tail-call-interp + --enable-optimizations (PGO) + --with-lto=full
• Parallel build with make -j
• Filesystem/limits: default container settings (no custom ulimit)

Quick knobs / workarounds that avoid the crash here

• Drop tail-call interpreter: build without --with-tail-call-interp.

Steps to reproduce (minimal)

  1. Extract CPython 3.14.0rc2.
  2. Configure exactly as shown (including --with-tail-call-interp).
  3. make -j$(nproc)
  4. Observe crash while generating Python/frozen_modules/*.h.

CPython versions tested on:

3.14.0rc2

Operating systems tested on:

Linux

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions