Skip to content

Argument Clinic: Py_buffer parameters are not initialized #64341

Closed

Description

@serhiy-storchaka
BPO 20142
Nosy @larryhastings, @serhiy-storchaka
Files
  • spammodule.c: An example
  • larry.clinic.py_buffer.initialization.patch.1.txt
  • 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/larryhastings'
    closed_at = <Date 2014-01-06.18:35:06.157>
    created_at = <Date 2014-01-06.14:05:53.013>
    labels = ['build', 'type-crash', 'release-blocker']
    title = 'Argument Clinic: Py_buffer parameters are not initialized'
    updated_at = <Date 2014-01-06.18:35:06.156>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2014-01-06.18:35:06.156>
    actor = 'larry'
    assignee = 'larry'
    closed = True
    closed_date = <Date 2014-01-06.18:35:06.157>
    closer = 'larry'
    components = ['Build']
    creation = <Date 2014-01-06.14:05:53.013>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['33326', '33330']
    hgrepos = []
    issue_num = 20142
    keywords = []
    message_count = 5.0
    messages = ['207433', '207456', '207460', '207461', '207466']
    nosy_count = 3.0
    nosy_names = ['larry', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue20142'
    versions = ['Python 3.4']

    Activity

    1. serhiy-storchaka commented on Jan 6, 2014

      @serhiy-storchaka
      MemberAuthor

      Argument Clinic doesn't initialize Py_buffer parameters. It generates cleanup code:

          /* Cleanup for data */
          if (data.buf)
             PyBuffer_Release(&data);

      And if PyArg_ParseTuple() is failed, the buf attribute can contains arbitrary (non-NULL) data. This causes crash in PyBuffer_Release(). See bpo-20133 for working example.

    2. larryhastings commented on Jan 6, 2014

      @larryhastings
      Contributor

      Here's a patch, please review. You can see how Py_buffer variables are initialized in zlibmodule.c in the patch.

    3. serhiy-storchaka commented on Jan 6, 2014

      @serhiy-storchaka
      MemberAuthor

      LGTM.

      But is not {NULL} enough for Py_buffer initialization?

    4. serhiy-storchaka commented on Jan 6, 2014

      @serhiy-storchaka
      MemberAuthor

      Or perhaps we should introduce macros Py_buffer_INIT.

    5. python-dev commented on Jan 6, 2014

      python-devmannequin
      Mannequin

      New changeset 16ff19d1d367 by Larry Hastings in branch 'default':
      Issue bpo-20142: Py_buffer variables generated by Argument Clinic are now
      http://hg.python.org/cpython/rev/16ff19d1d367

    6. self-assigned this
      on Jan 6, 2014
    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    buildThe build process and cross-buildrelease-blockertype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions