gh-155860: Reject a detached window in panel.replace() - #155861
Open
fedonman wants to merge 1 commit into
Open
Conversation
curses.screen.close() detaches the screen's standard window: the wrapper object stays alive but the curses window behind it is gone. panel.replace() did not check for that, so it stored the detached window in the panel and curses dereferenced it on the panel's next use, killing the interpreter with SIGSEGV. Raise curses.panel.error instead, the way new_panel() already does on the same window.
Documentation build overview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
curses.screen.close()detaches the screen's standard window: the wrapper object stays alive but the curses window behind it is gone.panel.replace()passed that window straight toreplace_panel(), so the panel ended up holding a NULL window and curses dereferenced it on the panel's next use.This adds the missing check before
replace_panel(), raisingcurses.panel.errorthe waynew_panel()already does when handed the same window.new_panel()is left alone: it already rejects the window, so there is nothing to fix there.The reproducer from the issue now stops at
replace()instead of dying:The new test fails without the change to
Modules/_curses_panel.c. With that hunk reverted it reportsFAIL, then takes the whole process down indel_panel()at teardown:With it, and the module as a whole, plus a refleak run:
No NEWS entry:
screen.close()is new in 3.16 and unreleased, so no released version can reach this crash. The change is news-exempt rather than missing an entry.panel.replace()is given a detached window #155860