GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — itertools.groupby() can fail a C assert() · Issue #74532 · python/cpython

itertools.groupby() can fail a C assert() #74532

New issue
Copy link
New issue
Copy link
Closed
Closed
itertools.groupby() can fail a C assert()#74532
Copy link
Assignees
serhiy-storchaka
Labels
3.7 (EOL)end of lifeend of lifeextension-modulesC modules in the Modules dirC modules in the Modules dirtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

Description

arigo
mannequin
opened on May 11, 2017
Issue body actions
BPO 30347
Nosy @arigo, @rhettinger, @serhiy-storchaka
PRs
  • bpo-30347: Fixed a crash in itertools.groupby() when use the grouper #1557
  • [3.6] bpo-30347: Stop crashes when concurrently iterate over itertools.groupby() iterators. (GH-1557) #3770
  • [2.7] bpo-30347: Stop crashes when concurrently iterate over itertools.groupby() iterators. (GH-1557). #3772
  • 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/serhiy-storchaka'
    closed_at = <Date 2017-09-26.20:16:27.494>
    created_at = <Date 2017-05-11.21:10:21.469>
    labels = ['extension-modules', '3.7', 'type-crash']
    title = 'itertools.groupby() can fail a C assert()'
    updated_at = <Date 2017-09-26.20:16:27.493>
    user = 'https://github.com/arigo'

    bugs.python.org fields:

    activity = <Date 2017-09-26.20:16:27.493>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2017-09-26.20:16:27.494>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules']
    creation = <Date 2017-05-11.21:10:21.469>
    creator = 'arigo'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30347
    keywords = ['patch']
    message_count = 8.0
    messages = ['293517', '293519', '293549', '293579', '302948', '303062', '303065', '303071']
    nosy_count = 3.0
    nosy_names = ['arigo', 'rhettinger', 'serhiy.storchaka']
    pr_nums = ['1557', '3770', '3772']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue30347'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7']

    Activity

    1. arigo commented on May 11, 2017

      @arigo
      arigomannequin
      on May 11, 2017
      MannequinAuthor
      More actions

      This triggers an assert() failure on debug-mode Python (or a leak in release Python):

      from itertools import groupby
      
      def f(n):
          print("enter:", n)
          if n == 5:
              list(b)
          print("leave:", n)
          return n != 6
      
      for (k, b) in groupby(range(10), f):
          print(list(b))

      With current trunk we get: python: ./Modules/itertoolsmodule.c:303: _grouper_next: Assertion `gbo->currkey == NULL' failed.

    2. arigo
      added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
      3.7 (EOL)end of lifeend of life
      type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
      on May 11, 2017
    3. serhiy-storchaka
      added
      extension-modulesC modules in the Modules dirC modules in the Modules dir
      and removed
      interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
      on May 11, 2017
    4. serhiy-storchaka
      assigned
      rhettinger
      on May 11, 2017
    5. rhettinger commented on May 11, 2017

      @rhettinger
      rhettinger
      on May 11, 2017
      Contributor
      More actions

      Do you have a suggested fix?

    6. serhiy-storchaka commented on May 12, 2017

      @serhiy-storchaka
      serhiy-storchaka
      on May 12, 2017
      Member
      More actions

      PR 1557 implements the simplest fix -- remove the assert and use Py_XSETREF() instead of simple assignment. Since the resulting code in _grouper_next() is identical to the code in groupby_next(), it was shared between these two functions.

    7. rhettinger commented on May 12, 2017

      @rhettinger
      rhettinger
      on May 12, 2017
      Contributor
      More actions

      At first glance, the suggested PR looks fine. Unless there is a rush, I would like to hold-off spend more time thinking about bpo-30346 before moving forward with this one.

    8. rhettinger
      assigned
      serhiy-storchaka
      and unassigned
      rhettinger
      on Sep 25, 2017
    9. serhiy-storchaka commented on Sep 25, 2017

      @serhiy-storchaka
      serhiy-storchaka
      on Sep 25, 2017
      Member
      More actions

      Hmm, the sole bpo-30346 is not enough for fixing this crash. I don't know if there is a simpler fix based on bpo-30346, but since PR 1557 removes the code duplication I'm going to merge it in any case.

    10. serhiy-storchaka commented on Sep 26, 2017

      @serhiy-storchaka
      serhiy-storchaka
      on Sep 26, 2017
      Member
      More actions

      New changeset c740e4f by Serhiy Storchaka in branch 'master':
      bpo-30347: Stop crashes when concurrently iterate over itertools.groupby() iterators. (bpo-1557)
      c740e4f

    11. serhiy-storchaka commented on Sep 26, 2017

      @serhiy-storchaka
      serhiy-storchaka
      on Sep 26, 2017
      Member
      More actions

      New changeset 69b2dc8 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.6':
      [3.6] bpo-30347: Stop crashes when concurrently iterate over itertools.groupby() iterators. (GH-1557) (bpo-3770)
      69b2dc8

    12. serhiy-storchaka commented on Sep 26, 2017

      @serhiy-storchaka
      serhiy-storchaka
      on Sep 26, 2017
      Member
      More actions

      New changeset d0b9dc3 by Serhiy Storchaka in branch '2.7':
      [2.7] bpo-30347: Stop crashes when concurrently iterate over itertools.groupby() iterators. (GH-1557). (bpo-3772)
      d0b9dc3

    13. serhiy-storchaka
      closed this as completedon Sep 26, 2017
    14. ezio-melotti
      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

    • @serhiy-storchaka
      serhiy-storchaka

    Labels

    3.7 (EOL)end of lifeend of lifeextension-modulesC modules in the Modules dirC modules in the Modules dirtype-crashA hard crash of the interpreter, possibly with a core dumpA 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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.