Re: [PATCH] Cygwin: exceptions: Fix AArch64 non-incyg signal handling

Jon Turney <[email protected]> Wed, 17 Jun 2026 12:07:44 +0100
Newsgroups gmane.os.cygwin.patches
Message-ID <[email protected]>
On 12/06/2026 09:02, Máte Dimand wrote:
> This patch fixes crashes that occur when a signal interrupts sigfe or
> any non-cygwin function that does not preserve the LR register in its
> prologue/epilogue. This crash was discovered through the "run-heredoc"
> testcase in bash's testsuite, which caused bash to call "read"
> frequently, leading to a high chance of a signal interrupting sigfe.

Interesting.

It seems like it should be possible to construct a relatively simple 
test to demonstrate this.  Could you suggest what that test might look like?

> The "sigdelayed" function in gendef clobbers the LR register to return
> to the instruction where the thread was interrupted. Picking any other
> register for branching back would also clobber said register. Leaf
> functions are not guaranteed to be compiled with LR being preserved on
> the stack. The solution is to use RtlRestoreContext to restore all
> registers without needing to sacrifice any.
> 
> The patch includes a C++ version of sigdelayed, which calls
> RtlRestoreContext at the end. The non-incyg signal handling codepath
> will change the thread's IP register to this new function instead of
> the original sigdelayed function written in assembly. Cygwin functions
> interrupted by signals still use the original function.

Hmmm... it seems like this is functionally incremental to a patch which 
hasn't been applied yet, but I can't work out which one.

> Signed-off-by: Máté Dimand <[email protected]>

Thanks.

> | git am
> warning: Patch sent with format=flowed; space at the end of lines might be lost.
> Applying: Cygwin: exceptions: Fix AArch64 non-incyg signal handling
> error: corrupt patch at line 11
> Patch failed at 0001 Cygwin: exceptions: Fix AArch64 non-incyg signal handling

I spent about an hour trying to salvage this, without success. Could I 
possibly trouble you to resend it as an attachment?