Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extern "C" around PyTraceMalloc_ functions. #127772

Merged
merged 1 commit into from
Dec 11, 2024
Merged

Conversation

hawkinsp
Copy link
Contributor

@hawkinsp hawkinsp commented Dec 9, 2024

Pretty much everything else exported by Python.h has an extern "C" annotation, yet this header appears to be missing one.

(Noticed because numpy/numpy@7124091 added an extern "C" around its include of <Python.h>, which should have been a no-op but wasn't in all cases.)

Copy link

cpython-cla-bot bot commented Dec 9, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Dec 9, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

How do we feel about backporting?

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. But please remove the two empty lines to be consistent with other header files.

Include/cpython/tracemalloc.h Outdated Show resolved Hide resolved
Include/cpython/tracemalloc.h Outdated Show resolved Hide resolved
@vstinner vstinner added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Dec 10, 2024
@ZeroIntensity
Copy link
Member

I don't think this affects 3.12

@vstinner
Copy link
Member

I don't think this affects 3.12

Python 3.12 is also affected, but the code is different.

Pretty much everything else exported by Python.h has an extern "C"
annotation, yet this header appears to be missing one.
@hawkinsp
Copy link
Contributor Author

LGTM.

How do we feel about backporting?

No strong opinions from my end. I was able to work around the problem. But I wanted to make sure to fix the issue upstream.

@vstinner vstinner merged commit 2cdeb61 into python:main Dec 11, 2024
39 checks passed
@miss-islington-app
Copy link

Thanks @hawkinsp for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 11, 2024
Pretty much everything else exported by Python.h has an extern "C"
annotation, yet this header appears to be missing one.
(cherry picked from commit 2cdeb61)

Co-authored-by: Peter Hawkins <[email protected]>
@miss-islington-app
Copy link

Sorry, @hawkinsp and @vstinner, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 2cdeb61b57e638ae46a04386330a12abe9cddf2c 3.12

@bedevere-app
Copy link

bedevere-app bot commented Dec 11, 2024

GH-127815 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Dec 11, 2024
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot aarch64 RHEL8 LTO + PGO 3.x has failed when building commit 2cdeb61.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/78/builds/8019) and take a look at the build logs.
  4. Check if the failure is related to this commit (2cdeb61) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/78/builds/8019

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.lto-pgo/build/Lib/threading.py", line 1054, in _bootstrap_inner
    self.run()
    ~~~~~~~~^^
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.lto-pgo/build/Lib/threading.py", line 996, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.lto-pgo/build/Lib/test/test_interpreters/test_stress.py", line 30, in task
    interp = interpreters.create()
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.lto-pgo/build/Lib/test/support/interpreters/__init__.py", line 76, in create
    id = _interpreters.create(reqrefs=True)
interpreters.InterpreterError: interpreter creation failed
k

vstinner pushed a commit to vstinner/cpython that referenced this pull request Dec 11, 2024
Pretty much everything else exported by Python.h has an extern "C"
annotation, yet this header appears to be missing one.

(cherry picked from commit 2cdeb61)
@bedevere-app
Copy link

bedevere-app bot commented Dec 11, 2024

GH-127817 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Dec 11, 2024
vstinner pushed a commit that referenced this pull request Dec 11, 2024
#127815)

Add `extern "C"` around `PyTraceMalloc_` functions. (GH-127772)

Pretty much everything else exported by Python.h has an extern "C"
annotation, yet this header appears to be missing one.
(cherry picked from commit 2cdeb61)

Co-authored-by: Peter Hawkins <[email protected]>
vstinner added a commit that referenced this pull request Dec 11, 2024
…127817)

Add `extern "C"` around `PyTraceMalloc_` functions. (#127772)

Pretty much everything else exported by Python.h has an extern "C"
annotation, yet this header appears to be missing one.

(cherry picked from commit 2cdeb61)

Co-authored-by: Peter Hawkins <[email protected]>
hawkinsp added a commit to hawkinsp/numpy that referenced this pull request Dec 12, 2024
This exposed a latent bug in CPython
(python/cpython#127772), but it's probably not a
good practice in general to wrap other code's headers with extern
guards.
hawkinsp added a commit to hawkinsp/numpy that referenced this pull request Dec 12, 2024
This extern block was recently moved, which exposed a latent bug in CPython
(python/cpython#127772), but it's probably not a
good practice in general to wrap other code's headers with extern
guards.
seberg pushed a commit to numpy/numpy that referenced this pull request Dec 12, 2024
This extern block was recently moved, which exposed a latent bug in CPython
(python/cpython#127772), but it's probably not a
good practice in general to wrap other code's headers with extern
guards.
charris pushed a commit to charris/numpy that referenced this pull request Dec 12, 2024
This extern block was recently moved, which exposed a latent bug in CPython
(python/cpython#127772), but it's probably not a
good practice in general to wrap other code's headers with extern
guards.
charris pushed a commit to charris/numpy that referenced this pull request Dec 12, 2024
This extern block was recently moved, which exposed a latent bug in CPython
(python/cpython#127772), but it's probably not a
good practice in general to wrap other code's headers with extern
guards.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants