From 6cd79d45df2fda2872a82302dc80628b1b80e69b Mon Sep 17 00:00:00 2001 From: 4g4 Date: Wed, 29 Apr 2026 15:27:52 +0800 Subject: [PATCH] bugfix: fix coredump when resizing terminal window In the signal handler for the signal SIGWINCH tty_term_resize, we call tty_dpy_invalidate function. In this function, we change the screen_size and other critical fields. While the process is executing the function tty_dpy_flush, and another SIGWINCH occurs, then the screen_size is changed. And tty_dpy_flush will access invalid memory which leads to coredump. In the signal hander of SIGWINCH, we only need to set the flag complete_refresh. --- qe.h | 2 +- tty.c | 6 +----- unix.c | 3 ++- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/qe.h b/qe.h index 7cbee10..898c063 100644 --- a/qe.h +++ b/qe.h @@ -110,7 +110,7 @@ void set_write_handler(int fd, void (*cb)(void *opaque), void *opaque); int set_pid_handler(int pid, void (*cb)(void *opaque, int status), void *opaque); void url_exit(void); -void url_redisplay(void); +void url_redisplay(QEditScreen *s); void register_bottom_half(void (*cb)(void *opaque), void *opaque); void unregister_bottom_half(void (*cb)(void *opaque), void *opaque); diff --git a/tty.c b/tty.c index 4b02055..10b37c4 100644 --- a/tty.c +++ b/tty.c @@ -658,11 +658,7 @@ static void tty_term_resize(qe__unused__ int sig) QEditScreen *s = tty_screen; if (s) { - tty_dpy_invalidate(s); - - //fprintf(stderr, "tty_term_resize: width=%d, height=%d\n", s->width, s->height); - - url_redisplay(); + url_redisplay(s); } } diff --git a/unix.c b/unix.c index 2dabcf9..39fdc77 100644 --- a/unix.c +++ b/unix.c @@ -346,9 +346,10 @@ void url_exit(void) } /* asynchronous redisplay signal received */ -void url_redisplay(void) +void url_redisplay(QEditScreen *s) { url_display_request = 1; + s->qs->complete_refresh = 1; } int get_clock_ms(void) {