Skip to content

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

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

Closed
michaelforney mannequin opened this issue May 19, 2021 · 1 comment
Closed

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

michaelforney mannequin opened this issue May 19, 2021 · 1 comment
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@michaelforney
Copy link
Mannequin

michaelforney mannequin commented May 19, 2021

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']

    @michaelforney
    Copy link
    Mannequin Author

    michaelforney mannequin commented May 19, 2021

    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

    @michaelforney michaelforney mannequin added 3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump labels May 19, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @erlend-aasland erlend-aasland moved this to Bugs in Curses issues May 20, 2022
    @github-project-automation github-project-automation bot moved this from Bugs to Done in Curses issues May 4, 2025
    @serhiy-storchaka serhiy-storchaka added 3.13 bugs and security fixes 3.14 bugs and security fixes and removed 3.11 only security fixes 3.10 only security fixes 3.9 only security fixes 3.8 (EOL) end of life 3.7 (EOL) end of life labels May 4, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.13 bugs and security fixes 3.14 bugs and security fixes extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    Status: Done
    Development

    No branches or pull requests

    1 participant