Menu ▾ ▴

Code Merge Request #3: Fix crashes on SIGWINCH (open)

Merging...

Merged

Something went wrong. Please, merge manually

Checking if merge is possible...

Something went wrong. Please, merge manually

Anders Kaseorg wants to merge 4 commits from /u/anders0/aa-project/ to master, 2026-10-06

Clear the iswaiting flag when we’re done waiting, to prevent a longjmp into a stack frame that already returned. Use sigsetjmp/siglongjmp to leave the signal handler. Consistently declare signal handler state variables as volatile sig_atomic_t.

Commit Date  
[014304] (aalib-sigwinch-fixes) by Anders Kaseorg Anders Kaseorg

aalib: Make variables shared with SIGWINCH handlers volatile sig_atomic_t.

A signal handler may only safely assign to objects of type volatile
sig_atomic_t, and the compiler must not cache or drop stores to the
iswaiting flags around the blocking reads. This also makes the
definitions of __resized_curses and __resized_slang agree with their
extern declarations, which were volatile int while the definitions
were plain int.

Co-Authored-By: Claude Opus 5.5 <noreply@...>

2026-10-05 23:44:28 Tree
[f39185] by Anders Kaseorg Anders Kaseorg

aalib: Use sigsetjmp/siglongjmp to leave the SIGWINCH handlers.

The keyboard drivers longjmp out of their SIGWINCH handler to interrupt
a blocking read. SIGWINCH is blocked while the handler runs, and plain
setjmp/longjmp don't restore the signal mask on glibc, so after the
first such jump SIGWINCH stayed blocked and later resizes were never
noticed. sigsetjmp(buf, 1) saves the mask so siglongjmp restores it.

Co-Authored-By: Claude Opus 5.5 <noreply@...>

2026-10-05 23:40:44 Tree
[2e0b33] by Anders Kaseorg Anders Kaseorg

aalib: Clear iswaiting on resize in the stdin keyboard driver.

When a resize interrupted a blocking stdin_getchar, it returned
AA_RESIZE with iswaiting still set, so the next SIGWINCH made the
handler longjmp into the stack frame of a call that had returned.

Co-Authored-By: Claude Opus 5.5 <noreply@...>

2026-10-05 23:40:28 Tree
[0f380b] by Anders Kaseorg Anders Kaseorg

aalib: Fix crash on resize in the curses keyboard driver.

curses_getchar sets iswaiting while waiting for a key so that the
SIGWINCH handler can longjmp out of the wait, but never cleared it.
After the first blocking aa_getkey, every later SIGWINCH made the
handler longjmp into the stack frame of a call that had long returned,
crashing the program when the terminal was resized. Clear iswaiting
when we stop waiting, as the slang driver does.

Co-Authored-By: Claude Opus 5.5 <noreply@...>

2026-10-05 23:26:35 Tree

Discussion


Log in to post a comment.