Skip to content

Conversation

@nascheme
Copy link
Member

@naschemenascheme commented Nov 25, 2024

These macros are not safe to use in the free-threaded build. Use PyCell_GetRef() and PyCell_SetTakeRef() instead. Add PyCell_GET to the free-threading howto table of APIs that return borrowed refs. Add critical sections to PyCell_GET and PyCell_SET.

Fix some thread safety issues with cell objects: cell_richcompare, cell_repr, cell_set_contents needed some work. Add an addtional unit test module that tries to trigger data races for these.

@naschemenascheme changed the title Replace use of PyCell_GET/SETgh-127271: Replace use of PyCell_GET/SETNov 25, 2024
These macros are not safe to use in the free-threaded build. Use `PyCell_GetRef()` and `PyCell_SetTakeRef()` instead. Add `PyCell_GET` to the free-threading howto table of APIs that return borrowed refs. Add critical sections to `PyCell_GET` and `PyCell_SET`.
@naschemenascheme requested a review from mpageNovember 27, 2024 21:06
@nascheme
Copy link
MemberAuthor

While tinkering with the cellobject code, I found a couple more data races. I've included the fixes for those in this PR.

For the reviewer, the reference counting changes to super_init_without_args are quite tricky and I'm not so confident that I didn't introduce a bug in one of the many infrequently taken branches. Most of the other changes are pretty simple. It's mostly about using strong references rather than borrowed ones. I don't think there should be any significant performance impact in the non-free-threaded build (couple extra incref/decref pairs but mostly in error handling branches).

Avoid the type error and return results as before.
Copy link
Contributor

@mpagempage left a comment

Choose a reason for hiding this comment

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

I kicked off benchmark runs for this change for both the default and free-threaded builds. I'll post the results here once they're ready, likely tomorrow morning.

@mpagempage added the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Dec 3, 2024
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @mpage for commit b09c4cf 🤖

If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Dec 3, 2024
@mpage
Copy link
Contributor

mpage commented Dec 3, 2024

Performance on the default build looks neutral.

@naschemenascheme merged commit fc5a0dc into python:mainDec 3, 2024
37 checks passed
@naschemenascheme deleted the gh-127271-cell-get-set branch December 3, 2024 18:33
@bedevere-bot
Copy link

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

Hi! The buildbot AMD64 Debian root 3.x has failed when building commit fc5a0dc.

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

Failed tests:

  • test.test_multiprocessing_fork.test_misc
  • test.test_multiprocessing_spawn.test_misc

Failed subtests:

  • test_large_pool - test.test_multiprocessing_fork.test_misc.MiscTestCase.test_large_pool
  • test_large_pool - test.test_multiprocessing_spawn.test_misc.MiscTestCase.test_large_pool

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

==

Click to see traceback logs
Traceback (most recent call last): File "<string>", line 1, in <module>from multiprocessing.forkserver import main; main(10, 11, ['__main__'], **{'sys_path': ['/root/buildarea/3.x.angelico-debian-amd64/build/target/lib/python314.zip', '/root/buildarea/3.x.angelico-debian-amd64/build/Lib', '/root/buildarea/3.x.angelico-debian-amd64/build/build/lib.linux-x86_64-3.14'], 'authkey_r': 13}) ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/forkserver.py", line 324, in main pid = os.fork() OSError: [Errno 12] Cannot allocate memory Traceback (most recent call last): File "/root/buildarea/3.x.angelico-debian-amd64/build/build/test_python_1438526æ/@test_1438526_tmpæ", line 4, in <module>with multiprocessing.Pool(200) as p: ~~~~~~~~~~~~~~~~~~~~^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/context.py", line 119, in Poolreturn Pool(processes, initializer, initargs, maxtasksperchild, context=self.get_context()) File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/pool.py", line 215, in __init__self._repopulate_pool() ~~~~~~~~~~~~~~~~~~~~~^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/pool.py", line 306, in _repopulate_poolreturnself._repopulate_pool_static(self._ctx, self.Process, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^self._processes, ^^^^^^^^^^^^^^^^...<3 lines>...self._maxtasksperchild, ^^^^^^^^^^^^^^^^^^^^^^^self._wrap_exception) ^^^^^^^^^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/pool.py", line 329, in _repopulate_pool_static w.start() ~~~~~~~^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/process.py", line 121, in startself._popen =self._Popen(self) ~~~~~~~~~~~^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/context.py", line 300, in _Popenreturn Popen(process_obj) File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/popen_forkserver.py", line 35, in __init__super().__init__(process_obj) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/popen_fork.py", line 20, in __init__self._launch(process_obj) ~~~~~~~~~~~~^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/popen_forkserver.py", line 59, in _launchself.pid = forkserver.read_signed(self.sentinel) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/forkserver.py", line 390, in read_signedraiseEOFError('unexpected EOF') EOFError: unexpected EOF --- Traceback (most recent call last): File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/_test_multiprocessing.py", line 6586, in test_large_pool rc, out, err = script_helper.assert_python_ok(testfn) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 182, in assert_python_okreturn _assert_python(True, *args, **env_vars) File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 167, in _assert_python res.fail(cmd_line) ~~~~~~~~^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 80, in failraiseAssertionError(f"Process return code is {exitcode}\n"...<10 lines>...f"---") AssertionError: Process return code is 1 command line: ['/root/buildarea/3.x.angelico-debian-amd64/build/python', '-X', 'faulthandler', '-I', '@test_1464490_tmpæ'] Traceback (most recent call last): File "<string>", line 1, in <module>from multiprocessing.forkserver import main; main(10, 11, ['__main__'], **{'sys_path': ['/root/buildarea/3.x.angelico-debian-amd64/build/target/lib/python314.zip', '/root/buildarea/3.x.angelico-debian-amd64/build/Lib', '/root/buildarea/3.x.angelico-debian-amd64/build/build/lib.linux-x86_64-3.14'], 'authkey_r': 13}) ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/forkserver.py", line 324, in main pid = os.fork() OSError: [Errno 12] Cannot allocate memory Traceback (most recent call last): File "/root/buildarea/3.x.angelico-debian-amd64/build/build/test_python_1464490æ/@test_1464490_tmpæ", line 4, in <module>with multiprocessing.Pool(200) as p: ~~~~~~~~~~~~~~~~~~~~^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/context.py", line 119, in Poolreturn Pool(processes, initializer, initargs, maxtasksperchild, context=self.get_context()) File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/pool.py", line 215, in __init__self._repopulate_pool() ~~~~~~~~~~~~~~~~~~~~~^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/pool.py", line 306, in _repopulate_poolreturnself._repopulate_pool_static(self._ctx, self.Process, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^self._processes, ^^^^^^^^^^^^^^^^...<3 lines>...self._maxtasksperchild, ^^^^^^^^^^^^^^^^^^^^^^^self._wrap_exception) ^^^^^^^^^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/pool.py", line 329, in _repopulate_pool_static w.start() ~~~~~~~^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/process.py", line 121, in startself._popen =self._Popen(self) ~~~~~~~~~~~^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/context.py", line 300, in _Popenreturn Popen(process_obj) File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/popen_forkserver.py", line 35, in __init__super().__init__(process_obj) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/popen_fork.py", line 20, in __init__self._launch(process_obj) ~~~~~~~~~~~~^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/popen_forkserver.py", line 59, in _launchself.pid = forkserver.read_signed(self.sentinel) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/forkserver.py", line 390, in read_signedraiseEOFError('unexpected EOF') EOFError: unexpected EOF --- Traceback (most recent call last): File "<string>", line 1, in <module>from multiprocessing.forkserver import main; main(10, 11, ['__main__'], **{'sys_path': ['/root/buildarea/3.x.angelico-debian-amd64/build/target/lib/python314.zip', '/root/buildarea/3.x.angelico-debian-amd64/build/Lib', '/root/buildarea/3.x.angelico-debian-amd64/build/build/lib.linux-x86_64-3.14'], 'authkey_r': 13}) ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/forkserver.py", line 324, in main pid = os.fork() OSError: [Errno 12] Cannot allocate memory Traceback (most recent call last): File "/root/buildarea/3.x.angelico-debian-amd64/build/build/test_python_1464488æ/@test_1464488_tmpæ", line 4, in <module>with multiprocessing.Pool(200) as p: ~~~~~~~~~~~~~~~~~~~~^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/context.py", line 119, in Poolreturn Pool(processes, initializer, initargs, maxtasksperchild, context=self.get_context()) File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/pool.py", line 215, in __init__self._repopulate_pool() ~~~~~~~~~~~~~~~~~~~~~^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/pool.py", line 306, in _repopulate_poolreturnself._repopulate_pool_static(self._ctx, self.Process, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^self._processes, ^^^^^^^^^^^^^^^^...<3 lines>...self._maxtasksperchild, ^^^^^^^^^^^^^^^^^^^^^^^self._wrap_exception) ^^^^^^^^^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/pool.py", line 329, in _repopulate_pool_static w.start() ~~~~~~~^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/process.py", line 121, in startself._popen =self._Popen(self) ~~~~~~~~~~~^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/context.py", line 300, in _Popenreturn Popen(process_obj) File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/popen_forkserver.py", line 35, in __init__super().__init__(process_obj) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/popen_fork.py", line 20, in __init__self._launch(process_obj) ~~~~~~~~~~~~^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/popen_forkserver.py", line 59, in _launchself.pid = forkserver.read_signed(self.sentinel) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/forkserver.py", line 390, in read_signedraiseEOFError('unexpected EOF') EOFError: unexpected EOF --- Traceback (most recent call last): File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/_test_multiprocessing.py", line 6586, in test_large_pool rc, out, err = script_helper.assert_python_ok(testfn) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 182, in assert_python_okreturn _assert_python(True, *args, **env_vars) File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 167, in _assert_python res.fail(cmd_line) ~~~~~~~~^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 80, in failraiseAssertionError(f"Process return code is {exitcode}\n"...<10 lines>...f"---") AssertionError: Process return code is 1 command line: ['/root/buildarea/3.x.angelico-debian-amd64/build/python', '-X', 'faulthandler', '-I', '@test_1459109_tmpæ'] Traceback (most recent call last): File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/_test_multiprocessing.py", line 6586, in test_large_pool rc, out, err = script_helper.assert_python_ok(testfn) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 182, in assert_python_okreturn _assert_python(True, *args, **env_vars) File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 167, in _assert_python res.fail(cmd_line) ~~~~~~~~^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 80, in failraiseAssertionError(f"Process return code is {exitcode}\n"...<10 lines>...f"---") AssertionError: Process return code is 1 command line: ['/root/buildarea/3.x.angelico-debian-amd64/build/python', '-X', 'faulthandler', '-I', '@test_1438526_tmpæ'] Traceback (most recent call last): File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/_test_multiprocessing.py", line 6586, in test_large_pool rc, out, err = script_helper.assert_python_ok(testfn) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 182, in assert_python_okreturn _assert_python(True, *args, **env_vars) File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 167, in _assert_python res.fail(cmd_line) ~~~~~~~~^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/support/script_helper.py", line 80, in failraiseAssertionError(f"Process return code is {exitcode}\n"...<10 lines>...f"---") AssertionError: Process return code is 1 command line: ['/root/buildarea/3.x.angelico-debian-amd64/build/python', '-X', 'faulthandler', '-I', '@test_1464488_tmpæ'] Traceback (most recent call last): File "<string>", line 1, in <module>from multiprocessing.forkserver import main; main(10, 11, ['__main__'], **{'sys_path': ['/root/buildarea/3.x.angelico-debian-amd64/build/target/lib/python314.zip', '/root/buildarea/3.x.angelico-debian-amd64/build/Lib', '/root/buildarea/3.x.angelico-debian-amd64/build/build/lib.linux-x86_64-3.14'], 'authkey_r': 13}) ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/forkserver.py", line 324, in main pid = os.fork() OSError: [Errno 12] Cannot allocate memory Traceback (most recent call last): File "/root/buildarea/3.x.angelico-debian-amd64/build/build/test_python_1459109æ/@test_1459109_tmpæ", line 4, in <module>with multiprocessing.Pool(200) as p: ~~~~~~~~~~~~~~~~~~~~^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/context.py", line 119, in Poolreturn Pool(processes, initializer, initargs, maxtasksperchild, context=self.get_context()) File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/pool.py", line 215, in __init__self._repopulate_pool() ~~~~~~~~~~~~~~~~~~~~~^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/pool.py", line 306, in _repopulate_poolreturnself._repopulate_pool_static(self._ctx, self.Process, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^self._processes, ^^^^^^^^^^^^^^^^...<3 lines>...self._maxtasksperchild, ^^^^^^^^^^^^^^^^^^^^^^^self._wrap_exception) ^^^^^^^^^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/pool.py", line 329, in _repopulate_pool_static w.start() ~~~~~~~^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/process.py", line 121, in startself._popen =self._Popen(self) ~~~~~~~~~~~^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/context.py", line 300, in _Popenreturn Popen(process_obj) File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/popen_forkserver.py", line 35, in __init__super().__init__(process_obj) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/popen_fork.py", line 20, in __init__self._launch(process_obj) ~~~~~~~~~~~~^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/popen_forkserver.py", line 59, in _launchself.pid = forkserver.read_signed(self.sentinel) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^ File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/multiprocessing/forkserver.py", line 390, in read_signedraiseEOFError('unexpected EOF') EOFError: unexpected EOF --- 

@nascheme
Copy link
MemberAuthor

I can't reproduce those two failing tests on my Debian dev machine. My guess is the failure is not related to this commit. I'll investigate some more though.

srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 8, 2025
* Replace uses of `PyCell_GET` and `PyCell_SET`. These macros are not safe to use in the free-threaded build. Use `PyCell_GetRef()` and `PyCell_SetTakeRef()` instead. * Since `PyCell_GetRef()` returns a strong rather than borrowed ref, some code restructuring was required, e.g. `frame_get_var()` returns a strong ref now. * Add critical sections to `PyCell_GET` and `PyCell_SET`. * Move critical_section.h earlier in the Python.h file. * Add `PyCell_GET` to the free-threading howto table of APIs that return borrowed refs. * Add additional unit tests for free-threading.
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
* Replace uses of `PyCell_GET` and `PyCell_SET`. These macros are not safe to use in the free-threaded build. Use `PyCell_GetRef()` and `PyCell_SetTakeRef()` instead. * Since `PyCell_GetRef()` returns a strong rather than borrowed ref, some code restructuring was required, e.g. `frame_get_var()` returns a strong ref now. * Add critical sections to `PyCell_GET` and `PyCell_SET`. * Move critical_section.h earlier in the Python.h file. * Add `PyCell_GET` to the free-threading howto table of APIs that return borrowed refs. * Add additional unit tests for free-threading.
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.

3 participants

@nascheme@bedevere-bot@mpage