Skip to content
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

Potential leak in pysqlite_connection_init() #76455

Closed
lelit mannequin opened this issue Dec 11, 2017 · 3 comments
Closed

Potential leak in pysqlite_connection_init() #76455

lelit mannequin opened this issue Dec 11, 2017 · 3 comments
Labels
performance Performance or resource usage

Comments

@lelit
Copy link
Mannequin

lelit mannequin commented Dec 11, 2017

BPO 32274
Nosy @lelit, @JulienPalard

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2017-12-11.10:43:28.511>
created_at = <Date 2017-12-11.09:41:12.965>
labels = ['invalid', 'performance']
title = 'Potential leak in pysqlite_connection_init()'
updated_at = <Date 2017-12-11.10:43:28.509>
user = 'https://github.com/lelit'

bugs.python.org fields:

activity = <Date 2017-12-11.10:43:28.509>
actor = 'lelit'
assignee = 'none'
closed = True
closed_date = <Date 2017-12-11.10:43:28.511>
closer = 'lelit'
components = []
creation = <Date 2017-12-11.09:41:12.965>
creator = 'lelit'
dependencies = []
files = []
hgrepos = []
issue_num = 32274
keywords = []
message_count = 3.0
messages = ['308021', '308024', '308025']
nosy_count = 2.0
nosy_names = ['lelit', 'mdk']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'resource usage'
url = 'https://bugs.python.org/issue32274'
versions = []

@lelit
Copy link
Mannequin Author

lelit mannequin commented Dec 11, 2017

The function calls sqlite3_open() that, if I understand its documentation correctly[#], returns a new connection object in all cases (that is, even on errors) with the only exception of "out of memory" (in which case it sets the second parameter to NULL).

I think that the new connection object should be immediately released in case of errors, passing it to sqlite3_close().

.. [#] http://sqlite.org/c3ref/open.html

@lelit lelit mannequin added the performance Performance or resource usage label Dec 11, 2017
@JulienPalard
Copy link
Member

I don't see a leak here: as long as nobody keep a reference to each connection objects, pysqlite_connection_dealloc will be called and will call the sqlite3_close.

In other words the sqlite3_close is called when the connection is destroyed, which happen when no reference are kept on the connection, indifferently of a success or a failure of the connection.

It's in Modules/_sqlite/connection.c

@lelit
Copy link
Mannequin Author

lelit mannequin commented Dec 11, 2017

You are right, thank you.

@lelit lelit mannequin closed this as completed Dec 11, 2017
@lelit lelit mannequin added the invalid label Dec 11, 2017
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage
Projects
None yet
Development

No branches or pull requests

1 participant