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

sqlite3.Cursor.close() crashes in case the Cursor object is uninitialized #75945

Closed
orenmn mannequin opened this issue Oct 11, 2017 · 7 comments
Closed

sqlite3.Cursor.close() crashes in case the Cursor object is uninitialized #75945

orenmn mannequin opened this issue Oct 11, 2017 · 7 comments
Labels
3.7 (EOL) end of life extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@orenmn
Copy link
Mannequin

orenmn mannequin commented Oct 11, 2017

BPO 31764
Nosy @vstinner, @orenmn
PRs
  • bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized #3958
  • [3.6] bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized (GH-3958) #4303
  • [2.7] bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized (GH-3958) #4333
  • 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-11-08.09:59:12.399>
    created_at = <Date 2017-10-11.19:09:18.400>
    labels = ['extension-modules', '3.7', 'type-crash']
    title = 'sqlite3.Cursor.close() crashes in case the Cursor object is uninitialized'
    updated_at = <Date 2017-11-08.09:59:12.398>
    user = 'https://github.com/orenmn'

    bugs.python.org fields:

    activity = <Date 2017-11-08.09:59:12.398>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-11-08.09:59:12.399>
    closer = 'vstinner'
    components = ['Extension Modules']
    creation = <Date 2017-10-11.19:09:18.400>
    creator = 'Oren Milman'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31764
    keywords = ['patch']
    message_count = 7.0
    messages = ['304172', '305693', '305694', '305701', '305813', '305815', '305816']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'Oren Milman']
    pr_nums = ['3958', '4303', '4333']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue31764'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7']

    @orenmn
    Copy link
    Mannequin Author

    orenmn mannequin commented Oct 11, 2017

    The following code causes a crash:
    import sqlite3
    cursor = sqlite3.Cursor.__new__(sqlite3.Cursor)
    cursor.close()

    this is because pysqlite_cursor_close() (in Modules/_sqlite/cursor.c) assumes
    that self->connection is not NULL, and passes it to pysqlite_check_thread(),
    which crashes.

    I would open a PR to fix this soon.

    @orenmn orenmn mannequin added 3.7 (EOL) end of life extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump labels Oct 11, 2017
    @vstinner
    Copy link
    Member

    vstinner commented Nov 7, 2017

    New changeset edb13ae by Victor Stinner (Oren Milman) in branch 'master':
    bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized (bpo-3958)
    edb13ae

    @vstinner
    Copy link
    Member

    vstinner commented Nov 7, 2017

    @oren: The 2.7 backport is not straighforward. Would you mind to backport the fix to 2.7, please?

    @vstinner
    Copy link
    Member

    vstinner commented Nov 7, 2017

    New changeset b0331c9 by Victor Stinner (Miss Islington (bot)) in branch '3.6':
    bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized (GH-3958) (bpo-4303)
    b0331c9

    @orenmn
    Copy link
    Mannequin Author

    orenmn mannequin commented Nov 8, 2017

    I opened bpo-4333 for 2.7, but it is quite straightforward.. Am i missing something?

    @vstinner
    Copy link
    Member

    vstinner commented Nov 8, 2017

    New changeset cd66d6d by Victor Stinner (Oren Milman) in branch '2.7':
    bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized (GH-4333)
    cd66d6d

    @vstinner
    Copy link
    Member

    vstinner commented Nov 8, 2017

    Thank you for the backport Oren, I already merged it into Python 2.7.

    Thanks Oren Milman for your bug report *and* for your bug fix!

    I opened bpo-4333 for 2.7, but it is quite straightforward.. Am i missing something?

    Sorry, I had to say that "git cherry-pick" failed on 2.7. I didn't check why ;-)

    @vstinner vstinner closed this as completed Nov 8, 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
    3.7 (EOL) end of life extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant