-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Segmentation Fault in _curses #120378
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
Comments
Here are some tests that show the problem in different places (i.e., a local fix to one of them might not fix the root issue): @requires_curses_func('resize_term')
def test_resize_term_initscr_segfault(self):
curses.initscr()
lines = cols = 40000
try:
curses.resize_term(lines, cols)
except:
pass
curses.initscr()
curses.initscr()
@requires_curses_func('resizeterm')
def test_resizeterm_initscr_segfault(self):
curses.initscr()
lines = cols = 40000
try:
curses.resizeterm(lines, cols)
except:
pass
curses.initscr()
curses.initscr()
def test_resize_term_refresh_segfault(self):
curses.initscr()
lines = cols = 40000
try:
curses.resize_term(lines, cols)
except:
pass
c = curses.initscr()
c.refresh() |
That doesn't seem like the case. If that was true, then nearly every call to the window object should segfault after import _curses
screen = _curses.initscr()
try:
_curses.resizeterm(35000, 1)
except:
screen.box() # This should segfault if stdscr is freed! As far as I can see, this is actually an upstream bug in curses. It seems that a failure in #include <curses.h>
int
main(void)
{
initscr();
if (resizeterm(35000, 1) < 0) {
puts("no good!");
}
wrefresh(stdscr);
return 0;
} I wasn't able to find any good workaround, so there's nothing that we can do on our end. I'll leave this open temporarily if anyone has any other ideas. |
cc @picnixz, you've been working on |
Not entirely sure that it's an issue in curses. The manual for
I suggest reporting the issue upstream to confirm or not the behaviour. |
I played around with this, and even manually reinitializing I'm closing this as an upstream issue and reporting it to the GNU mailing lists. |
According to GNU, it seems the function is erroneously documented as taking integers, while in reality they are |
I was corrected on the mailing list: the functions don't necessarily take |
This is actually an upstream problem in curses, and has been reported to them already: https://lists.gnu.org/archive/html/bug-ncurses/2024-09/msg00101.html This is a nice workaround in the meantime to prevent the segfault. Co-authored-by: Bénédikt Tran <[email protected]>
…thonGH-124555) This is actually an upstream problem in curses, and has been reported to them already: https://lists.gnu.org/archive/html/bug-ncurses/2024-09/msg00101.html This is a nice workaround in the meantime to prevent the segfault. (cherry picked from commit c2ba931) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]>
…es` (pythonGH-124555) This is actually an upstream problem in curses, and has been reported to them already: https://lists.gnu.org/archive/html/bug-ncurses/2024-09/msg00101.html This is a nice workaround in the meantime to prevent the segfault. (cherry picked from commit c2ba931) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]>
Fixed by c2ba931 in the main branch, backports will follow. |
Thanks for your bug report @kcatss. |
…H-124555) (#124911) This is actually an upstream problem in curses, and has been reported to them already: https://lists.gnu.org/archive/html/bug-ncurses/2024-09/msg00101.html This is a nice workaround in the meantime to prevent the segfault. (cherry picked from commit c2ba931) Co-authored-by: Bénédikt Tran <[email protected]>
…H-124555) (#124905) gh-120378: Fix crash caused by integer overflow in `curses` (GH-124555) This is actually an upstream problem in curses, and has been reported to them already: https://lists.gnu.org/archive/html/bug-ncurses/2024-09/msg00101.html This is a nice workaround in the meantime to prevent the segfault. (cherry picked from commit c2ba931) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]>
Crash report
What happened?
Build
Root Cause
When calling
_curses.initscr
, initialised is set to True. Then, if_curses.resizeterm
is called with an improper size for the first argument, an error occurs, andstdscr
is freed. The error does not terminate even when wrapped in a try-except block.Because initialised is set to True, a second call to
_curses.initscr
invokeswrefresh(stdscr)
even thoughstdscr
has already been freed.cpython/Modules/_cursesmodule.c
Lines 3265 to 3283 in 34e4d32
POC
ASAN
asan
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.14.0a0 (heads/main:34f5ae69fe, Jun 9 2024, 21:27:54) [GCC 11.4.0]
Linked PRs
curses
#124555curses
(GH-124555) #124905curses
(GH-124555) #124911The text was updated successfully, but these errors were encountered: