| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Thank you to Eryk Sun for finding the cause of the bug and providing the code fix.
Previously, our ctypes_patch would trigger a bug in ctypes (see https://bugs.python.org/issue36880 and python/cpython#13364), which would eventually crash Python if done too often. This workaround changes our ctypes_patch implementation so that it no longer triggers the ctypes bug. This fixes the crash reported in beeware/toga#549.
|
I don't feel competent to review ctypes issues, sorry. Perhaps @serhiy-storchaka |
Sorry, something went wrong.
There was a problem hiding this comment.
There are merge conflicts.
Sorry, something went wrong.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request. |
Sorry, something went wrong.
# Conflicts: # Modules/_ctypes/callbacks.c
|
Fixed the conflict, thanks. I have made the requested changes; please review again. |
Sorry, something went wrong.
|
Thanks for making the requested changes! @isidentical, @kumaraditya303: please review the changes made to this pull request. |
Sorry, something went wrong.
| @support.refcount_test | ||
| def test_callback_py_object_none_return(self): |
There was a problem hiding this comment.
AFAICT, this test is rendered pointless in 3.12 due to the adoption of PEP 683 (Immortal Objects, Using a Fixed Refcount). Because None is immortal, executing Py_INCREF(Py_None) and Py_DECREF(Py_None) will no longer modify its refcount.
Sorry, something went wrong.
There was a problem hiding this comment.
Ah, good to know. I assume this isn't implemented yet though, because as of the current state of main (447d061), this test still hard-crashes without the fix.
Sorry, something went wrong.
| # Allow for small variations in None's refcount from other | ||
| # sources. | ||
| self.assertAlmostEqual( | ||
| sys.getrefcount(None), none_refcount, delta=50) |
There was a problem hiding this comment.
Yeah, in general we don't do these kind of tests. We have an automatic refleak detection mechanism but it will only work if the path that leaks references is exercised in the test suite. This means that you can add a test that ensures that the code you are adding to callbacks.c is actually executed but your test doesn't need to try to detect the refleak, that will be done automatically. I suppose the reason this was never detected is that we don't have a test that actually runs that.
Sorry, something went wrong.
There was a problem hiding this comment.
Ah okay. I was going by what the other tests in test_refcounts are doing. Should I adjust those as well to not check sys.getrefcount manually?
Sorry, something went wrong.
There was a problem hiding this comment.
Should I adjust those as well to not check sys.getrefcount manually?
Not as part of this issue (one issue per problem - only changing what's required for the problem at hand). I haven't checked those and maybe these are checked more specific things.
Sorry, something went wrong.
There was a problem hiding this comment.
You can confirm that your test work running `./python -m test test_ctypes -R'.
Ensure that it detects the problem without your fix first :)
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks, I didn't know that just -m test works too (I used -m test.regrtest). Yes, I checked - with -R it now indeed detects the original problem.
Sorry, something went wrong.
Co-authored-by: Eryk Sun <eryksun@gmail.com>
| return None | ||
|
|
||
| # Check that calling func does not affect None's refcount. | ||
| for _ in range(10000): |
There was a problem hiding this comment.
Single call should be enough to trigger the refleak checker.
Sorry, something went wrong.
There was a problem hiding this comment.
Unfortunately not... I tested again - apparently the refleak checker (with default settings: -m test --huntrleaks=: test.test_ctypes.test_refcounts) only detects if None's refcount is too high, not if it's too low. The latter case is only detected once None's refcount gets to zero/negative (which triggers an assertion), and that requires a thousand or so iterations of the broken code.
Sorry, something went wrong.
There was a problem hiding this comment.
If None refcount goes too small it will crash at some point assuming the rest of the code decrements normally
Sorry, something went wrong.
There was a problem hiding this comment.
Unfortunately not... I tested again - apparently the refleak checker (with default settings: -m test --huntrleaks=: test.test_ctypes.test_refcounts) only detects if None's refcount is too high, not if it's too low. The latter case is only detected once None's refcount gets to zero/negative (which triggers an assertion), and that requires a thousand or so iterations of the broken code.
I see, it is because of #74959.
Sorry, something went wrong.
|
🤖 New build scheduled with the buildbot fleet by @kumaraditya303 for commit 66ea175 🤖 If you want to schedule another build, you need to add the :hammer: test-with-refleak-buildbots label again. |
Sorry, something went wrong.
|
Buildbots are happy, merging. Thanks for the PR. |
Sorry, something went wrong.
|
Thanks @dgelessus for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
Sorry, something went wrong.
|
GH-100877 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
|
GH-100878 is a backport of this pull request to the 3.10 branch. |
Sorry, something went wrong.
…es.py_object` callback (pythonGH-13364) (cherry picked from commit 837ba05) Co-authored-by: dgelessus <dgelessus@users.noreply.github.com>
…es.py_object` callback (pythonGH-13364) (cherry picked from commit 837ba05) Co-authored-by: dgelessus <dgelessus@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Right now this only adds a failing test for the issue, to check that the bug is properly detected in CI. Once that runs through I'll push the commit with the actual fix. Done
https://bugs.python.org/issue36880