Skip to content

curses module may call delwin() on original window before subwindows #88338

Description

@michaelforney
BPO 44172
Nosy @michaelforney
PRs
  • bpo-44172: Keep reference to original window in curses subwindow objects #26226
  • 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 = None
    created_at = <Date 2021-05-19.02:08:10.843>
    labels = ['3.8', '3.9', '3.10', '3.11', 'extension-modules', '3.7', 'type-crash']
    title = 'curses module may call delwin() on original window before subwindows'
    updated_at = <Date 2021-05-19.02:24:53.341>
    user = 'https://github.com/michaelforney'

    bugs.python.org fields:

    activity = <Date 2021-05-19.02:24:53.341>
    actor = 'michaelforney'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Extension Modules']
    creation = <Date 2021-05-19.02:08:10.843>
    creator = 'michaelforney'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44172
    keywords = ['patch']
    message_count = 1.0
    messages = ['393916']
    nosy_count = 1.0
    nosy_names = ['michaelforney']
    pr_nums = ['26226']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue44172'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    1. michaelforney commented on May 19, 2021

      michaelforneymannequin
      MannequinAuthor

      When subwin() is used to create a subwindow for an original window, it does not keep a reference to the original window object. This can result in the original window getting deleted with delwin() before the subwindow.

      According to the X/Open curses specification[0]:

      The application must delete subwindows before deleting the main window.

      This is also mentioned in the ncurses documentation[1]:

      Subwindows must be deleted before the main window can be deleted.

      When building the Python curses module against NetBSD's curses implementation, deleting the windows in the wrong order causes a double-free. This results in hanging or crashing when running test_curses.

      To fix this, window objects for subwindows should keep a reference to the original window object.

      [0] https://pubs.opengroup.org/onlinepubs/7908799/xcurses/delwin.html
      [1] https://invisible-island.net/ncurses/man/curs_window.3x.html

    2. transferred this issue fromon Apr 10, 2022
    3. added
      3.13only security fixes
      3.14bugs and security fixes
      and removed
      3.11only security fixes
      on May 4, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.13only security fixes3.14bugs and security fixesextension-modulesC modules in the Modules dirtype-crashA hard crash of the interpreter, possibly with a core dump

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions