-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
bpo-31770: Prevent a crash and refleaks when calling sqlite3.Cursor.__init__() more than once #3968
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
vstinner
merged 6 commits into
python:master
from
orenmn:bpo31770-fix-crash-and-refleaks
Nov 7, 2017
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6f30a1d
init commit
orenmn 15f071a
added a NEWS.d item and a test.
orenmn 497ced8
improve the test's comment
orenmn 617c45a
Merge branch 'master' into bpo31770-fix-crash-and-refleaks
orenmn 82dfbf8
improve the test.
orenmn 51bb341
changed the test to include both 'del ref' and the call to gc_collect()
orenmn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Library/2017-10-12-18-45-38.bpo-31770.GV3MPx.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Prevent a crash when calling the ``__init__()`` method of a | ||
``sqlite3.Cursor`` object more than once. Patch by Oren Milman. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the purpose of removing explicitly the last reference to a weak reference object. Just remove "del ref" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least on my Windows 10, when the test fails, the
del ref
causes the crash info that is printed to include the line (and test) that caused the crash(i.e.
File "C:\Users\orenm\cpython\lib\sqlite3\test\regression.py", line 392 in CheckBpo31770
). If i remove thedel ref
, it doesn't show info about the line and test that caused the crash.If you still think that i should remove it, i wouldn't mind, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add
test.support.gc_collect()
for ensuring that objects are collected.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When i use
test.support.gc_collect()
, the crash info also doesn't include the line and the test that crashed.Also, when i add
1/0
after the call togc_collect()
, and run the test (on cpython without the patch in C code), the code doesn't crash ingc_collect()
, and aZeroDivisionError
is raised...(of course, without the
1/0
, it does crash, but after thegc_collect()
, i guess.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should i replace the
del ref
with a call totest.support.gc_collect()
anyway?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you call
test.support.gc_collect()
instead ofdel ref
? Or addingtest.support.gc_collect()
afterdel ref
breaks the test?I meant that you should keep
del ref
, but calltest.support.gc_collect()
after it for sure. Of course, if this breaks the test, don't add it.