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

PyImport_ReInitLock() doesn't check for allocation error #68186

Closed
tiran opened this issue Apr 18, 2015 · 4 comments
Closed

PyImport_ReInitLock() doesn't check for allocation error #68186

tiran opened this issue Apr 18, 2015 · 4 comments
Assignees
Labels
easy type-bug An unexpected behavior, bug, or error

Comments

@tiran
Copy link
Member

tiran commented Apr 18, 2015

BPO 23998
Nosy @brettcannon, @tiran
Files
  • import_reinit_fatal.patch
  • 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 = 'https://github.com/tiran'
    closed_at = <Date 2015-04-20.14:52:14.763>
    created_at = <Date 2015-04-18.22:42:35.033>
    labels = ['easy', 'type-bug']
    title = "PyImport_ReInitLock() doesn't check for allocation error"
    updated_at = <Date 2015-04-20.14:52:14.762>
    user = 'https://github.com/tiran'

    bugs.python.org fields:

    activity = <Date 2015-04-20.14:52:14.762>
    actor = 'christian.heimes'
    assignee = 'christian.heimes'
    closed = True
    closed_date = <Date 2015-04-20.14:52:14.763>
    closer = 'christian.heimes'
    components = []
    creation = <Date 2015-04-18.22:42:35.033>
    creator = 'christian.heimes'
    dependencies = []
    files = ['39110']
    hgrepos = []
    issue_num = 23998
    keywords = ['patch', 'easy', 'buildbot']
    message_count = 4.0
    messages = ['241462', '241517', '241547', '241656']
    nosy_count = 3.0
    nosy_names = ['brett.cannon', 'christian.heimes', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue23998'
    versions = ['Python 2.7', 'Python 3.3', 'Python 3.4', 'Python 3.5']

    @tiran
    Copy link
    Member Author

    tiran commented Apr 18, 2015

    _PyImport_ReInitLock() doesn't check the return value of PyThread_allocate_lock(). A failed lock allocation can either lead to a NULL pointer dereference or to race conditions caused by a missing import lock.

    As there is no way to recover from a failed lock allication I recommend to abort with a fatal error.

    CID 1295025 (#1 of 1): Dereference after null check (FORWARD_NULL)
    var_deref_model: Passing null pointer import_lock to PyThread_acquire_lock, which dereferences it.

    @tiran tiran added easy type-bug An unexpected behavior, bug, or error labels Apr 18, 2015
    @brettcannon
    Copy link
    Member

    LGTM

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 19, 2015

    New changeset d70995cf44b3 by Christian Heimes in branch '2.7':
    Issue bpo-23998: PyImport_ReInitLock() now checks for lock allocation error
    https://hg.python.org/cpython/rev/d70995cf44b3

    New changeset 7d7bf5c34d7e by Christian Heimes in branch '3.3':
    Issue bpo-23998: PyImport_ReInitLock() now checks for lock allocation error
    https://hg.python.org/cpython/rev/7d7bf5c34d7e

    New changeset e0bd083fc9c1 by Christian Heimes in branch '3.4':
    Issue bpo-23998: PyImport_ReInitLock() now checks for lock allocation error
    https://hg.python.org/cpython/rev/e0bd083fc9c1

    New changeset 7ae8fd62d743 by Christian Heimes in branch 'default':
    Issue bpo-23998: PyImport_ReInitLock() now checks for lock allocation error
    https://hg.python.org/cpython/rev/7ae8fd62d743

    @tiran
    Copy link
    Member Author

    tiran commented Apr 20, 2015

    Thanks, Brett!

    @tiran tiran closed this as completed Apr 20, 2015
    @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
    easy type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants