GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [3.12] `extern "C"` not closed in tracemalloc.h when using Py_LIMITED_API · Issue #127902 · python/cpython

[3.12] extern "C" not closed in tracemalloc.h when using Py_LIMITED_API #127902

New issue
Copy link
New issue
Copy link
Closed
Closed
[3.12] extern "C" not closed in tracemalloc.h when using Py_LIMITED_API#127902
Copy link
Labels
3.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@mitya57
mitya57
opened on Dec 13, 2024
Issue body actions

Bug report

Bug description:

When building PyQt6 with the latest 3.12 branch, I get the following error:

g++ -c -pipe -g -O2 -ffile-prefix-map=/pyqt6=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -fno-exceptions -Wall -Wextra -D_REENTRANT -fPIC -DPy_LIMITED_API=0x03090000 -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_CORE_LIB -I. -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/python3.12 -I/usr/include/x86_64-linux-gnu/qt6 -I/usr/include/x86_64-linux-gnu/qt6/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt6/mkspecs/linux-g++ -o dbus.o ../../../../dbus/dbus.cpp
In file included from /usr/include/c++/14/utility:68,
                 from /usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:15,
                 from /usr/include/x86_64-linux-gnu/qt6/QtCore/qcoreapplication.h:7,
                 from /usr/include/x86_64-linux-gnu/qt6/QtCore/QCoreApplication:1,
                 from ../../../../dbus/dbus.cpp:29:
/usr/include/c++/14/bits/stl_relops.h:86:5: error: template with C linkage
   86 |     template <class _Tp>
      |     ^~~~~~~~
In file included from /usr/include/python3.12/Python.h:107,
                 from /usr/include/dbus-1.0/dbus/dbus-python.h:34,
                 from ../../../../dbus/dbus.cpp:27:
/usr/include/python3.12/tracemalloc.h:4:1: note: ‘extern "C"’ linkage started here
    4 | extern "C" {
      | ^~~~~~~~~~

This happened because of the commit 65bca19, which changed the structure of tracemalloc.h to the following:

#ifndef Py_TRACEMALLOC_H
#define Py_TRACEMALLOC_H
#ifdef __cplusplus
extern "C" {
#endif

#ifndef Py_LIMITED_API
/* ... */

#ifdef __cplusplus
}
#endif
#endif /* !Py_LIMITED_API */
#endif /* !Py_TRACEMALLOC_H */

Here, if Py_LIMITED_API is defined, the extern "C" block is opened but never closed.

This problem does not affect 3.13 and newer versions, because the order is different there. I am going to submit a trivial pull request to fix this.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

  • [3.12] gh-127902: Make sure extern "C" is closed when using Py_LIMITED_API #127904
  • [3.12] gh-127906: Backport test_cext from the main branch #127912

Activity

  1. mitya57
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Dec 13, 2024
  2. mitya57
    added a commit that references this issue on Dec 13, 2024

    [3.12] pythongh-127902: Make sure `extern "C"` is closed when using P…

    8e2bed4
  3. eendebakpt commented on Dec 13, 2024

    @eendebakpt
    eendebakpt
    on Dec 13, 2024
    Contributor
    More actions

    @mitya57 Thanks for reporting. Making a PR would nice!

    @vstinner Is there a reason why this was not noticed by the CI? I checked the CI on your PR #127817 and it was all green

  4. eendebakpt
    added
    3.12only security fixesonly security fixes
    on Dec 13, 2024
  5. vstinner commented on Dec 13, 2024

    @vstinner
    vstinner
    on Dec 13, 2024
    Member
    More actions

    Oops, thanks for catching this regression!

    Is there a reason why this was not noticed by the CI?

    The limited C API is not well tested in Python 3.12.

  6. vstinner
    added a commit that references this issue on Dec 13, 2024

    [3.12] gh-127902: Make sure `extern "C"` is closed when using Py_LIMI…

    b184f48
  7. vstinner commented on Dec 13, 2024

    @vstinner
    vstinner
    on Dec 13, 2024
    Member
    More actions

    Fixed by change b184f48.

  8. vstinner
    closed this as completedon Dec 13, 2024
  9. vstinner commented on Dec 13, 2024

    @vstinner
    vstinner
    on Dec 13, 2024
    Member
    More actions

    The limited C API is not well tested in Python 3.12.

    I created #127906 to add more tests to 3.12.

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.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.