Skip to content

bpo-45385: Fix reference leak from descr_check#28719

Merged
corona10 merged 1 commit into
python:mainfrom
corona10:nit
Oct 7, 2021
Merged

bpo-45385: Fix reference leak from descr_check#28719
corona10 merged 1 commit into
python:mainfrom
corona10:nit

Conversation

@corona10

@corona10 corona10 commented Oct 4, 2021

Copy link
Copy Markdown
Member

motivation:

  • GH detects the compiler warnings while executing the CI pipeline.
  • Fix possible reference leak for the method_check_args use-case.

https://bugs.python.org/issue45385

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Your commit title is misleading. What your PR does it is to fix compiler warnings in Objects/descrobject.c. It's unrelated to GitHub Action. It's just that you noticed them thanks for GHA.

Comment thread Objects/descrobject.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe descr_check() should set res to NULL when it returns 0, whereas having to modify all functions using it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you modify descr_check() for that, maybe add a comment to explain that it's only set to NULL to prevent compiler warnings.

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

motivation: #28572

Can you please mention the fixed compiler warning in the commit message?

@corona10 corona10 changed the title no-issue: Remove compiler warning from Github Action. no-issue: Fix compiler warnings in Objects/descrobject.c. Oct 4, 2021
@corona10 corona10 changed the title no-issue: Fix compiler warnings in Objects/descrobject.c. no-issue: Fix compiler warnings in Objects/descrobject.c Oct 4, 2021
@vstinner

vstinner commented Oct 4, 2021

Copy link
Copy Markdown
Member

motivation: #28572

I don't see the relationship between your PR and the PR #28572.

@corona10

corona10 commented Oct 4, 2021

Copy link
Copy Markdown
Member Author

I don't see the relationship between your PR and the PR #28572.

I detected the warning from the PR but I will update the content not to mention the PR :)

@corona10
corona10 requested a review from vstinner October 4, 2021 10:06
Comment thread Objects/descrobject.c Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@vstinner
Thanks Victor for review :)
Is this what you intended?

@corona10

corona10 commented Oct 4, 2021

Copy link
Copy Markdown
Member Author

comparison of integer expressions of different signedness: ‘long unsigned int’ and ‘int’ [-Wsign-compare]

Will be fixed at #28716

@Fidget-Spinner Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM in general. Thank you!

Comment thread Objects/descrobject.c Outdated
Comment thread Objects/descrobject.c Outdated
Comment thread Objects/descrobject.c Outdated
Comment thread Objects/descrobject.c Outdated
Comment thread Objects/descrobject.c Outdated
@corona10
corona10 requested a review from vstinner October 4, 2021 15:13
Comment thread Objects/descrobject.c Outdated
@corona10 corona10 changed the title no-issue: Fix compiler warnings in Objects/descrobject.c bpo-45385: Fix compiler warnings in Objects/descrobject.c Oct 6, 2021
@corona10 corona10 changed the title bpo-45385: Fix compiler warnings in Objects/descrobject.c bpo-45385: Fix possible reference leak from descr_check Oct 6, 2021
@corona10

corona10 commented Oct 6, 2021

Copy link
Copy Markdown
Member Author

@vstinner @Fidget-Spinner
PTAL, this PR will fix both compiler warning and possible ref leak :)

@corona10 corona10 added the needs backport to 3.10 only security fixes label Oct 6, 2021
Comment thread Objects/descrobject.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would you mind to use Py_NewRef()?

@Fidget-Spinner Fidget-Spinner Oct 6, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we can, the bugfix needs to be backported to 3.9. Py_NewRef was added in 3.10. Unless you mean Py_NewRef for 3.11, 3.10 and manual backport for 3.9.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

3.10 backport should not prevent to write better code in the main branch. The backport can be different.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@vstinner @Fidget-Spinner
I will backport it manually :)

@Fidget-Spinner Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Just needs a news IMO.

Comment thread Objects/descrobject.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wow, why did this (and the code below) change too? I don't think this was buggy, though the new code improves readability/makes it easier to understand.

I'm guessing for consistency reasons?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I asked @corona10 to mention compiler warnings in the commit message. I cannot see compiler warnings in https://bugs.python.org/issue45385, in the PR description, or in the commit message.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm guessing for consistency reasons?

Yes and it improve the readability :)

Comment thread Objects/descrobject.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is no need to cast the Py_NewRef() argument to PyObject*.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated!

@corona10
corona10 requested a review from vstinner October 6, 2021 14:04

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. But please mention the fixed compiler warnings in the commit message and/or in the bpo.

"Fix possible reference leak". Either there is a leak or not leak. I suggest to remove "possible".

@corona10 corona10 changed the title bpo-45385: Fix possible reference leak from descr_check bpo-45385: Fix reference leak from descr_check Oct 6, 2021
@Fidget-Spinner Fidget-Spinner added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Oct 6, 2021
@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @Fidget-Spinner for commit 336434c 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Oct 6, 2021
@corona10 corona10 self-assigned this Oct 6, 2021
@corona10
corona10 merged commit e6ff4eb into python:main Oct 7, 2021
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @corona10 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

@corona10: Please replace # with GH- in the commit message next time. Thanks!

@bedevere-bot

Copy link
Copy Markdown

GH-28779 is a backport of this pull request to the 3.10 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 7, 2021
(cherry picked from commit e6ff4eb)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
@corona10
corona10 deleted the nit branch October 7, 2021 00:52
@bedevere-bot

Copy link
Copy Markdown

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

Hi! The buildbot x86-64 macOS 3.x has failed when building commit e6ff4eb.

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

Failed tests:

  • test_importlib

Failed subtests:

  • test_multiprocessing_pool_circular_import - test.test_importlib.test_threaded_import.ThreadedImportTests

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

== Tests result: FAILURE then FAILURE ==

408 tests OK.

10 slowest tests:

  • test_concurrent_futures: 4 min 29 sec
  • test_multiprocessing_spawn: 4 min
  • test_unparse: 3 min 26 sec
  • test_tokenize: 3 min 17 sec
  • test_lib2to3: 2 min 29 sec
  • test_multiprocessing_forkserver: 2 min 17 sec
  • test_unicodedata: 2 min 9 sec
  • test_asyncio: 1 min 57 sec
  • test_capi: 1 min 41 sec
  • test_pickle: 1 min 15 sec

1 test failed:
test_importlib

18 tests skipped:
test_devpoll test_epoll test_gdb test_ioctl test_msilib
test_multiprocessing_fork test_ossaudiodev test_smtpnet test_spwd
test_ssl test_startfile test_tix test_tk test_ttk_guionly
test_winconsoleio test_winreg test_winsound test_zipfile64

1 re-run test:
test_importlib

Total duration: 29 min 19 sec

Click to see traceback logs
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/multiprocessing/resource_tracker.py", line 209, in main
    cache[rtype].remove(name)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: '/psm_660b9f0f'


Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/test/test_importlib/test_threaded_import.py", line 258, in test_multiprocessing_pool_circular_import
    script_helper.assert_python_ok(fn)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/test/support/script_helper.py", line 160, in assert_python_ok
    return _assert_python(True, *args, **env_vars)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/test/support/script_helper.py", line 145, in _assert_python
    res.fail(cmd_line)
    ^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/test/support/script_helper.py", line 72, in fail
    raise AssertionError("Process return code is %d\n"
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Process return code is 1
command line: ['/Users/buildbot/buildarea/3.x.billenstein-macos/build/python.exe', '-X', 'faulthandler', '-I', '/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/test/test_importlib/partial/pool_in_threads.py']


Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/multiprocessing/resource_tracker.py", line 209, in main
    cache[rtype].remove(name)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: '/psm_660c8d6e'

corona10 added a commit to corona10/cpython that referenced this pull request Oct 7, 2021
(cherry picked from commit e6ff4eb)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
corona10 added a commit that referenced this pull request Oct 7, 2021
…8780)

(cherry picked from commit e6ff4eb)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
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.

6 participants