Skip to content

gh-128923: Use zero to indicate unassigned unique id - #128925

Merged
Yhg1s merged 6 commits into
python:mainfrom
colesbury:gh-128923-unique-id
Jan 17, 2025
Merged

gh-128923: Use zero to indicate unassigned unique id#128925
Yhg1s merged 6 commits into
python:mainfrom
colesbury:gh-128923-unique-id

Conversation

@colesbury

@colesburycolesbury commented Jan 16, 2025

Copy link
Copy Markdown
Contributor

In the free threading build, the per thread reference counting uses a unique id for some objects to index into the local reference count table. Use 0 instead of -1 to indicate that the id is not assigned. This avoids bugs where zero-initialized heap type objects look like they have a unique id assigned.

In the free threading build, the per thread reference counting uses a
unique id for some objects to index into the local reference count
table. Use 0 instead of -1 to indicate that the id is not assigned. This
avoids bugs where zero-initialized heap type objects look like they have
a unique id assigned.
Comment threadInclude/internal/pycore_object.h
Comment threadModules/_testcapimodule.c Outdated
Comment threadObjects/codeobject.c Outdated
Comment threadPython/uniqueid.c Outdated
colesburyand others added 2 commits January 17, 2025 10:10
Co-authored-by: T. Wouters <thomas@python.org>
@colesbury
colesbury requested a review from Yhg1sJanuary 17, 2025 15:19
@Yhg1s
Yhg1s merged commit d66c08a into python:mainJan 17, 2025
@bedevere-bot

Copy link
Copy Markdown

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

Hi! The buildbot aarch64 Android 3.x has failed when building commit d66c08a.

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/1594/builds/1046) and take a look at the build logs.
  4. Check if the failure is related to this commit (d66c08a) 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/1594/builds/1046

Failed tests:

  • test.test_pydoc.test_pydoc

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

==

Click to see traceback logs
Traceback (most recent call last):
File "/data/user/0/org.python.testbed/files/python/lib/python3.14/test/test_pydoc/test_pydoc.py", line 559, in test_builtin_with_more_than_four_children
text = doc.docclass(object)
File "/data/user/0/org.python.testbed/files/python/lib/python3.14/pydoc.py", line 1436, in docclass
subclasses =sorted(
(str(cls.__name__) forclsintype.__subclasses__(object)
ifnotcls.__name__.startswith("_") andcls.__module__=="builtins"),
key=str.lower
)
File "/data/user/0/org.python.testbed/files/python/lib/python3.14/pydoc.py", line 1438, in <genexpr>ifnotcls.__name__.startswith("_") andcls.__module__=="builtins"),
^^^^^^^^^^^^^^AttributeError: __module__. Did you mean: '__reduce__'?

@bedevere-bot

Copy link
Copy Markdown

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

Hi! The buildbot iOS ARM64 Simulator 3.x has failed when building commit d66c08a.

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/1380/builds/2346) and take a look at the build logs.
  4. Check if the failure is related to this commit (d66c08a) 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/1380/builds/2346

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

==

Click to see traceback logs
Traceback (most recent call last):

@bedevere-bot

Copy link
Copy Markdown

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

Hi! The buildbot AMD64 Android 3.x has failed when building commit d66c08a.

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/1591/builds/937) and take a look at the build logs.
  4. Check if the failure is related to this commit (d66c08a) 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/1591/builds/937

Failed tests:

  • test.test_pydoc.test_pydoc

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

==

Click to see traceback logs
Traceback (most recent call last):
File "/data/user/0/org.python.testbed/files/python/lib/python3.14/test/test_pydoc/test_pydoc.py", line 559, in test_builtin_with_more_than_four_children
text = doc.docclass(object)
File "/data/user/0/org.python.testbed/files/python/lib/python3.14/pydoc.py", line 1436, in docclass
subclasses =sorted(
(str(cls.__name__) forclsintype.__subclasses__(object)
ifnotcls.__name__.startswith("_") andcls.__module__=="builtins"),
key=str.lower
)
File "/data/user/0/org.python.testbed/files/python/lib/python3.14/pydoc.py", line 1438, in <genexpr>ifnotcls.__name__.startswith("_") andcls.__module__=="builtins"),
^^^^^^^^^^^^^^AttributeError: __module__. Did you mean: '__reduce__'?

@Yhg1s

Yhg1s commented Jan 17, 2025

Copy link
Copy Markdown
Member

Re: the buildbot failures, they're happening because the newly added heaptype inherits from object and does not have the __module__ attribute. Given that creating classes this way (and them not having __module__) isn't inherently wrong, I think the correct fix is to make pydoc robust against this.

@Yhg1s

Copy link
Copy Markdown
Member

#128951 should fix the buildbot failures. (This wasn't picked up by GHA because we apparently have no GHA that runs the tests in a single process/sequentially.)

srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 21, 2025
…8925)
In the free threading build, the per thread reference counting uses a
unique id for some objects to index into the local reference count
table. Use 0 instead of -1 to indicate that the id is not assigned. This
avoids bugs where zero-initialized heap type objects look like they have
a unique id assigned.
@colesbury
colesbury deleted the gh-128923-unique-id branch February 28, 2025 15:04
Sign up for freeto 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.

4 participants

@colesbury@bedevere-bot@Yhg1s@mpage