Skip to content

3.15.0a2 doesn't compile with CFLAGS=-DNDEBUG and --with-pydebug #142038

Description

@xhochy

Bug report

Bug description:

When configured using ./configure --with-pydebug (and explicitly not using --with-assertions), the build fails with:

+ make -j2 -C build-shared EXTRA_CFLAGS= LIBRARY=libpython3.15t-pic.a libpython3.15t-pic.a
make: Entering directory '/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/build-shared'
x86_64-conda-linux-gnu-gcc -pthread -c -fno-strict-overflow -Wsign-compare -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -Og -Wall -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O0 -ffunction-sections -pipe -isystem /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work=/usr/local/src/conda/python-3.15.0a2 -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol=/usr/local/src/conda-prefix -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O0 -ffunction-sections -pipe -isystem /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work=/usr/local/src/conda/python-3.15.0a2 -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol=/usr/local/src/conda-prefix  -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden  -I/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/internal -I/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/internal/mimalloc -IObjects -IInclude -IPython -I. -I/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include -DNDEBUG -D_FORTIFY_SOURCE=2 -O0 -isystem /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -I/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O0 -isystem /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -I/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -fPIC -DPy_BUILD_CORE -o Objects/typeobject.o /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Objects/typeobject.c
x86_64-conda-linux-gnu-gcc -pthread -c -fno-strict-overflow -Wsign-compare -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -Og -Wall -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O0 -ffunction-sections -pipe -isystem /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work=/usr/local/src/conda/python-3.15.0a2 -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol=/usr/local/src/conda-prefix -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O0 -ffunction-sections -pipe -isystem /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work=/usr/local/src/conda/python-3.15.0a2 -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol=/usr/local/src/conda-prefix  -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden  -I/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/internal -I/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/internal/mimalloc -IObjects -IInclude -IPython -I. -I/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include -DNDEBUG -D_FORTIFY_SOURCE=2 -O0 -isystem /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -I/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O0 -isystem /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -I/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/include -fPIC -DPy_BUILD_CORE -o Objects/unicode_format.o /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Objects/unicode_format.c
In file included from /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_build_env/x86_64-conda-linux-gnu/sysroot/usr/include/assert.h:36,
                 from /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/Python.h:20,
                 from /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Objects/unicode_format.c:43:
/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_build_env/x86_64-conda-linux-gnu/sysroot/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
  330 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
      |    ^~~~~~~
In file included from /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_build_env/x86_64-conda-linux-gnu/sysroot/usr/include/assert.h:36,
                 from /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/Python.h:20,
                 from /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Objects/typeobject.c:3:
/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/_build_env/x86_64-conda-linux-gnu/sysroot/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
  330 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
      |    ^~~~~~~
In file included from /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/internal/pycore_weakref.h:11,
                 from /home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Objects/typeobject.c:24:
/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/internal/pycore_critical_section.h: In function '_PyCriticalSection_AssertHeld':
/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/internal/pycore_critical_section.h:221:29: warning: unused variable 'cs' [-Wunused-variable]
  221 |         PyCriticalSection2 *cs = (PyCriticalSection2 *)(prev & ~_Py_CRITICAL_SECTION_MASK);
      |                             ^~
/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/internal/pycore_critical_section.h:225:28: warning: unused variable 'cs' [-Wunused-variable]
  225 |         PyCriticalSection *cs = (PyCriticalSection *)(tstate->critical_section & ~_Py_CRITICAL_SECTION_MASK);
      |                            ^~
/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/internal/pycore_critical_section.h: In function '_PyCriticalSection_AssertHeldObj':
/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/internal/pycore_critical_section.h:240:29: warning: unused variable 'cs' [-Wunused-variable]
  240 |         PyCriticalSection2 *cs = (PyCriticalSection2 *)(prev & ~_Py_CRITICAL_SECTION_MASK);
      |                             ^~
/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/internal/pycore_critical_section.h:246:28: warning: unused variable 'cs' [-Wunused-variable]
  246 |         PyCriticalSection *cs = (PyCriticalSection *)(prev & ~_Py_CRITICAL_SECTION_MASK);
      |                            ^~
/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Include/internal/pycore_critical_section.h:236:14: warning: unused variable 'mutex' [-Wunused-variable]
  236 |     PyMutex *mutex = &_PyObject_CAST(op)->ob_mutex;
      |              ^~~~~
/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Objects/typeobject.c: In function 'set_tp_bases':
/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Objects/typeobject.c:106:10: error: implicit declaration of function 'types_world_is_stopped' [-Wimplicit-function-declaration]
  106 |     if (!types_world_is_stopped()) { _Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(TYPE_LOCK); }
      |          ^~~~~~~~~~~~~~~~~~~~~~
/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Objects/typeobject.c:113:33: note: in expansion of macro 'ASSERT_TYPE_LOCK_HELD'
  113 |     if (TYPE_IS_REVEALED(tp)) { ASSERT_TYPE_LOCK_HELD(); }
      |                                 ^~~~~~~~~~~~~~~~~~~~~
/home/conda/feedstock_root/build_artifacts/python-split_1764324859162/work/Objects/typeobject.c:604:5: note: in expansion of macro 'ASSERT_NEW_TYPE_OR_LOCKED'
  604 |     ASSERT_NEW_TYPE_OR_LOCKED(self);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~

This was introduced in #140133 which tried to fix #133177

CPython versions tested on:

3.15

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Nov 28, 2025
  2. added a commit that references this issue on Nov 28, 2025
  3. added
    buildThe build process and cross-build
    3.15bugs and security fixes
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    on Nov 28, 2025
  4. vstinner commented on Dec 2, 2025

    @vstinner
    Member

    I cannot reproduce this issue.

    When configured using ./configure --with-pydebug

    Are you sure that you used exactly ./configure --with-pydebug?

  5. xhochy commented on Dec 2, 2025

    @xhochy
    ContributorAuthor

    No, I'm using more than this. This popped up while setting up the build for conda-forge conda-forge/python-feedstock#833 I'll try to produce a minimal example.

  6. vstinner commented on Dec 2, 2025

    @vstinner
    Member

    Can you provide the whole configure command and/or logs including the command?

  7. xhochy commented on Dec 3, 2025

    @xhochy
    ContributorAuthor

    This fails (see conda-forge/python-feedstock#835 and conda-forge/python-feedstock#837 ):

    ./configure --prefix=$PREFIX --build=x86_64-conda-linux-gnu --host=x86_64-conda-linux-gnu --enable-ipv6 --with-ensurepip=no --with-tzpath=$PREFIX/share/zoneinfo --with-computed-gotos --with-system-expat --enable-loadable-sqlite-extensions --with-tcltk-includes=-I$PREFIX/include '--with-tcltk-libs=-L$PREFIX/lib -ltcl8.6 -ltk8.6' --with-platlibdir=lib --enable-experimental-jit=no --disable-gil --with-pydebug --oldincludedir=$BUILD_PREFIX/x86_64-conda-linux-gnu/sysroot/usr/include --enable-shared
    

    Full log: 19.txt

    But removing --disable-gil makes the build pass (which makes sense as the whole block is guarded with #ifdef Py_GIL_DISABLED)

    ./configure --prefix=$PREFIX--disable-gil --with-pydebug was also sufficient to trigger this, but I realised that we were setting -DNDEBUG externally. Thus:

    I guess my fix is not the right one here. Should we instead add a test to configure to check that NDEBUG is not part of the CFLAGS if a debug build has been requested?

  8. changed the title [-]3.15.0a2 doesn't compile with `--with-pydebug`[/-] [+]3.15.0a2 doesn't compile with `CFLAGS=-DNDEBUG` and `--with-pydebug`[/+] on Dec 3, 2025
  9. vstinner commented on Dec 3, 2025

    @vstinner
    Member

    Oh ok, I can reproduce the build failure with:

    ./configure --with-pydebug --disable-gil CFLAGS="-DNDEBUG"
    

    Well, it's uncommon to disable assertions in a debug build. But we should support it.

  10. added a commit that references this issue on Dec 3, 2025
  11. vstinner commented on Dec 3, 2025

    @vstinner
    Member

    I merged your fix. Thanks.

  12. added a commit that references this issue on Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.15bugs and security fixesbuildThe build process and cross-buildinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions