Skip to content

Fix possible refleak in CodeType.replace() #106243

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

Merged
merged 1 commit into from
Jun 29, 2023

Conversation

serhiy-storchaka
Copy link
Member

A reference to c_code was leaked if PySys_Audit() failed.

A reference to c_code was leaked if PySys_Audit() failed.
@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the refleak-code-replace branch June 29, 2023 14:22
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 29, 2023
A reference to c_code was leaked if PySys_Audit() failed.
(cherry picked from commit 3c70d46)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-bot
Copy link

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

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Jun 29, 2023
@bedevere-bot
Copy link

GH-106245 is a backport of this pull request to the 3.11 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 29, 2023
A reference to c_code was leaked if PySys_Audit() failed.
(cherry picked from commit 3c70d46)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jun 29, 2023
serhiy-storchaka added a commit that referenced this pull request Jun 29, 2023
)

Fix possible refleak in CodeType.replace() (GH-106243)

A reference to c_code was leaked if PySys_Audit() failed.
(cherry picked from commit 3c70d46)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this pull request Jun 29, 2023
)

Fix possible refleak in CodeType.replace() (GH-106243)

A reference to c_code was leaked if PySys_Audit() failed.
(cherry picked from commit 3c70d46)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-bot
Copy link

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

Hi! The buildbot AMD64 Arch Linux TraceRefs 3.12 has failed when building commit 2405929.

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/all/#builders/1197/builds/102) and take a look at the build logs.
  4. Check if the failure is related to this commit (2405929) 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/all/#builders/1197/builds/102

Failed tests:

  • test__xxsubinterpreters
  • test_capi

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

==

Click to see traceback logs
remote: Enumerating objects: 4, done.        
remote: Counting objects:  25% (1/4)        
remote: Counting objects:  50% (2/4)        
remote: Counting objects:  75% (3/4)        
remote: Counting objects: 100% (4/4)        
remote: Counting objects: 100% (4/4), done.        
remote: Compressing objects:  25% (1/4)        
remote: Compressing objects:  50% (2/4)        
remote: Compressing objects:  75% (3/4)        
remote: Compressing objects: 100% (4/4)        
remote: Compressing objects: 100% (4/4), done.        
remote: Total 4 (delta 0), reused 2 (delta 0), pack-reused 0        
From https://github.com/python/cpython
 * branch                  3.12       -> FETCH_HEAD
Note: switching to '2405929c35239580aa0344f0e8fd31b87f9ccfe9'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 2405929c35 [3.12] Fix possible refleak in CodeType.replace() (GH-106243) (GH-106244)
Switched to and reset branch '3.12'

Objects/object.c:2211: _Py_ForgetReference: Assertion failed: invalid object chain
Enable tracemalloc to get the memory block allocation traceback

object address  : 0x7f3134ef0530
object refcount : 0
object type     : 0x55e113f364a0
object type name: tuple_iterator
object repr     : <refcnt 0 at 0x7f3134ef0530>

Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed
Python runtime state: initialized

Thread 0x00007f3136be86c0 (most recent call first):
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/test_capi/test_misc.py", line 1589 in do_work
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/threading.py", line 989 in run
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/threading.py", line 1052 in _bootstrap_inner
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/threading.py", line 1009 in _bootstrap

Current thread 0x00007f3138277740 (most recent call first):
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/threading.py", line 1130 in join
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/support/threading_helper.py", line 144 in start_threads
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/contextlib.py", line 144 in __exit__
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/test_capi/test_misc.py", line 1609 in test_isolated_subinterpreter
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/case.py", line 589 in _callTestMethod
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/case.py", line 634 in run
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/case.py", line 690 in __call__
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/suite.py", line 122 in run
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/suite.py", line 84 in __call__
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/suite.py", line 122 in run
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/suite.py", line 84 in __call__
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/suite.py", line 122 in run
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/suite.py", line 84 in __call__
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/suite.py", line 122 in run
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/suite.py", line 84 in __call__
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/suite.py", line 122 in run
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/suite.py", line 84 in __call__
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/unittest/runner.py", line 240 in run
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/support/__init__.py", line 1115 in _run_suite
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/support/__init__.py", line 1241 in run_unittest
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/libregrtest/runtest.py", line 294 in _test_module
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/libregrtest/runtest.py", line 330 in _runtest_inner2
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/libregrtest/runtest.py", line 373 in _runtest_inner
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/libregrtest/runtest.py", line 248 in _runtest
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/libregrtest/runtest.py", line 278 in runtest
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/libregrtest/main.py", line 365 in rerun_failed_tests
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/libregrtest/main.py", line 783 in _main
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/libregrtest/main.py", line 738 in main
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/libregrtest/main.py", line 802 in main
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/test/__main__.py", line 2 in <module>
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/runpy.py", line 88 in _run_code
  File "/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/Lib/runpy.py", line 198 in _run_module_as_main

Extension modules: _testcapi, _xxsubinterpreters, _testmultiphase, _testsinglephase, _testinternalcapi (total: 5)
make: *** [Makefile:2015: buildbottest] Aborted (core dumped)

Cannot open file '/buildbot/buildarea/3.12.pablogsal-arch-x86_64/build/test-results.xml' for upload

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.

3 participants