Skip to content

./configure --with-assertions generates a broken build #82557

Closed

Description

@vsajip
BPO 38376
Nosy @Yhg1s, @vsajip, @vstinner
PRs
  • bpo-38376: Fix build error when enabling assertions but not Py_DEBUG. #16594
  • bpo-36389: _PyObject_CheckConsistency() now also works in release mode #16612
  • [3.8] bpo-38376: Fix _PyUnicode_CheckConsistency() definition #16623
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-10-07.20:39:08.601>
    created_at = <Date 2019-10-05.12:43:51.221>
    labels = ['type-bug', '3.8', '3.9', 'build']
    title = './configure --with-assertions generates a broken build'
    updated_at = <Date 2019-10-15.01:06:21.081>
    user = 'https://github.com/vsajip'

    bugs.python.org fields:

    activity = <Date 2019-10-15.01:06:21.081>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-10-07.20:39:08.601>
    closer = 'vstinner'
    components = ['Build']
    creation = <Date 2019-10-05.12:43:51.221>
    creator = 'vinay.sajip'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38376
    keywords = ['patch']
    message_count = 10.0
    messages = ['354006', '354007', '354011', '354014', '354070', '354118', '354129', '354139', '354140', '354680']
    nosy_count = 3.0
    nosy_names = ['twouters', 'vinay.sajip', 'vstinner']
    pr_nums = ['16594', '16612', '16623']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38376'
    versions = ['Python 3.8', 'Python 3.9']

    Activity

    1. vsajip commented on Oct 5, 2019

      @vsajip
      MemberAuthor

      Following

      ./configure --prefix=$HOME/.local --with-assertions

      and then running make leads to an error:

      $ make
      gcc -pthread -c -Wno-unused-result -Wsign-compare -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration  -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE -o Objects/codeobject.o Objects/codeobject.c
      gcc -pthread -c -Wno-unused-result -Wsign-compare -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration  -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE -o Objects/complexobject.o Objects/complexobject.c
      gcc -pthread -c -Wno-unused-result -Wsign-compare -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration  -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE -o Objects/descrobject.o Objects/descrobject.c
      In file included from ./Include/object.h:746:0,
                       from ./Include/pytime.h:6,
                       from ./Include/Python.h:85,
                       from Objects/descrobject.c:3:
      ./Include/object.h:111:38: error: expected ‘)’ before ‘*’ token
       #define _PyObject_CAST(op) ((PyObject*)(op))
                                            ^
      ./Include/cpython/object.h:337:36: note: in definition of macro ‘PyType_HasFeature’
       #define PyType_HasFeature(t,f)  (((t)->tp_flags & (f)) != 0)
                                          ^
      ./Include/unicodeobject.h:115:18: note: in expansion of macro ‘PyType_FastSubclass’
                        PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
                        ^
      ./Include/object.h:122:34: note: in expansion of macro ‘_PyObject_CAST’
       #define Py_TYPE(ob)             (_PyObject_CAST(ob)->ob_type)
                                        ^
      ./Include/unicodeobject.h:115:38: note: in expansion of macro ‘Py_TYPE’
                        PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
                                            ^
      ./Include/unicodeobject.h:1042:56: note: in expansion of macro ‘PyUnicode_Check’
       #define _PyUnicode_CheckConsistency(op, check_content) PyUnicode_Check(op)
                                                              ^
      ./Include/internal/pycore_object.h:14:17: note: in expansion of macro ‘_PyUnicode_CheckConsistency’
       PyAPI_FUNC(int) _PyUnicode_CheckConsistency(PyObject *op, int check_content);
                       ^
      ./Include/object.h:111:40: error: expected ‘)’ before ‘(’ token
       #define _PyObject_CAST(op) ((PyObject*)(op))
                                              ^
      ./Include/cpython/object.h:337:36: note: in definition of macro ‘PyType_HasFeature’
       #define PyType_HasFeature(t,f)  (((t)->tp_flags & (f)) != 0)
                                          ^
      ./Include/unicodeobject.h:115:18: note: in expansion of macro ‘PyType_FastSubclass’
                        PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
                        ^
      ./Include/object.h:122:34: note: in expansion of macro ‘_PyObject_CAST’
       #define Py_TYPE(ob)             (_PyObject_CAST(ob)->ob_type)
                                        ^
      ./Include/unicodeobject.h:115:38: note: in expansion of macro ‘Py_TYPE’
                        PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
                                            ^
      ./Include/unicodeobject.h:1042:56: note: in expansion of macro ‘PyUnicode_Check’
       #define _PyUnicode_CheckConsistency(op, check_content) PyUnicode_Check(op)
                                                              ^
      ./Include/internal/pycore_object.h:14:17: note: in expansion of macro ‘_PyUnicode_CheckConsistency’
       PyAPI_FUNC(int) _PyUnicode_CheckConsistency(PyObject *op, int check_content);
                       ^
      ./Include/object.h:122:52: error: expected ‘)’ before ‘->’ token
       #define Py_TYPE(ob)             (_PyObject_CAST(ob)->ob_type)
                                                          ^
      ./Include/cpython/object.h:337:36: note: in definition of macro ‘PyType_HasFeature’
       #define PyType_HasFeature(t,f)  (((t)->tp_flags & (f)) != 0)
                                          ^
      ./Include/unicodeobject.h:115:18: note: in expansion of macro ‘PyType_FastSubclass’
                        PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
                        ^
      ./Include/unicodeobject.h:115:38: note: in expansion of macro ‘Py_TYPE’
                        PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
                                            ^
      ./Include/unicodeobject.h:1042:56: note: in expansion of macro ‘PyUnicode_Check’
       #define _PyUnicode_CheckConsistency(op, check_content) PyUnicode_Check(op)
                                                              ^
      ./Include/internal/pycore_object.h:14:17: note: in expansion of macro ‘_PyUnicode_CheckConsistency’
       PyAPI_FUNC(int) _PyUnicode_CheckConsistency(PyObject *op, int check_content);
                       ^
      ./Include/cpython/object.h:337:38: error: expected ‘)’ before ‘->’ token
       #define PyType_HasFeature(t,f)  (((t)->tp_flags & (f)) != 0)
                                            ^
      ./Include/object.h:351:35: note: in expansion of macro ‘PyType_HasFeature’
       #define PyType_FastSubclass(t,f)  PyType_HasFeature(t,f)
                                         ^
      ./Include/unicodeobject.h:115:18: note: in expansion of macro ‘PyType_FastSubclass’
                        PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
                        ^
      ./Include/unicodeobject.h:1042:56: note: in expansion of macro ‘PyUnicode_Check’
       #define _PyUnicode_CheckConsistency(op, check_content) PyUnicode_Check(op)
                                                              ^
      ./Include/internal/pycore_object.h:14:17: note: in expansion of macro ‘_PyUnicode_CheckConsistency’
       PyAPI_FUNC(int) _PyUnicode_CheckConsistency(PyObject *op, int check_content);
                       ^
      ./Include/cpython/object.h:337:56: error: expected ‘)’ before ‘!=’ token
       #define PyType_HasFeature(t,f)  (((t)->tp_flags & (f)) != 0)
                                                              ^
      ./Include/object.h:351:35: note: in expansion of macro ‘PyType_HasFeature’
       #define PyType_FastSubclass(t,f)  PyType_HasFeature(t,f)
                                         ^
      ./Include/unicodeobject.h:115:18: note: in expansion of macro ‘PyType_FastSubclass’
                        PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
                        ^
      ./Include/unicodeobject.h:1042:56: note: in expansion of macro ‘PyUnicode_Check’
       #define _PyUnicode_CheckConsistency(op, check_content) PyUnicode_Check(op)
                                                              ^
      ./Include/internal/pycore_object.h:14:17: note: in expansion of macro ‘_PyUnicode_CheckConsistency’
       PyAPI_FUNC(int) _PyUnicode_CheckConsistency(PyObject *op, int check_content);
                       ^
      Makefile:1711: recipe for target 'Objects/descrobject.o' failed
      make: *** [Objects/descrobject.o] Error 1

      BTW, this happens even if Py_DEBUG=true is defined. System where the failure occurred: Ubuntu 16.04, 64-bit.

    2. added
      3.9 (EOL)
      build
      type-bug
      on Oct 5, 2019
    3. vsajip commented on Oct 5, 2019

      @vsajip
      MemberAuthor

      BTW it also seems to fail when just Py_DEBUG is specified (no --with-assertions).

    4. vsajip commented on Oct 5, 2019

      @vsajip
      MemberAuthor

      Adding Thomas and Victor based on git blame on some of the source lines concerned.

    5. Yhg1s commented on Oct 5, 2019

      @Yhg1s
      Member

      The problem is _PyUnicode_CheckConsistency switched from being only defined when Py_DEBUG is set, to being defined unconditionally. That was a good change, but it made the API-compatibility hack of #defining _PyUnicode_CheckConsistency in Include/unicodeobject.h do the wrong thing. PR bpo-16594.

    6. vstinner commented on Oct 7, 2019

      @vstinner
      Member

      My intent in bpo-36389 was to also provide _PyObject_CheckConsistency() in release mode to help debugging GC crash, especially in visit_decref(). I wrote PR 16612 to fix my implementation.

    7. vstinner commented on Oct 7, 2019

      @vstinner
      Member

      New changeset 6876257 by Victor Stinner in branch 'master':
      bpo-36389: _PyObject_CheckConsistency() available in release mode (GH-16612)
      6876257

    8. vstinner commented on Oct 7, 2019

      @vstinner
      Member

      New changeset 435b2ee by Victor Stinner in branch '3.8':
      bpo-38376: Fix _PyUnicode_CheckConsistency() definition (GH-16623)
      435b2ee

    9. vstinner commented on Oct 7, 2019

      @vstinner
      Member

      After pushing some fixes to 3.8 and master branches, I tested the following commands in 3.7, 3.8 and master branches:

      make distclean
      ./configure --prefix=$HOME/.local --with-assertions
      make
      ./python -m test -j0 test_bytes test_gc test_capi

      These commands now work in the 3 branches. I close the issue.

      Thanks Vinay Sajip for the bug report! Thanks T. Wouters for previous fixes.

      @t. Wouters: I took the liberty of closing your PR 16594 in favor of my PR 16623. I may backport PR 16612 enhancements to 3.8 later, but not jus before a 3.8.0 final release to no stress our release manager ;-)

    10. vstinner commented on Oct 15, 2019

      @vstinner
      Member

      New changeset f82ce5b by Victor Stinner in branch '3.8':
      [3.8] bpo-36389: Backport debug enhancements from master (GH-16796)
      f82ce5b

    11. transferred this issue fromon Apr 10, 2022
    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.8 (EOL)3.9 (EOL)buildtype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions