You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
curses module may call delwin() on original window before subwindows #88338
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=Noneclosed_at=Nonecreated_at=<Date2021-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=<Date2021-05-19.02:24:53.341>user='https://github.com/michaelforney'
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.
Activity
michaelforney commentedon 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]:
This is also mentioned in the ncurses documentation[1]:
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