Skip to content

Cygwin: pipe: Fix hang due to inadvertent 0-length raw_write() and some signal fixes #91

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

Merged
merged 3 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions winsup/cygwin/exceptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,13 @@ _cygtls::call_signal_handler ()
to 16 byte. */
uintptr_t new_sp = ((uintptr_t) _my_tls.altstack.ss_sp
+ _my_tls.altstack.ss_size) & ~0xf;
/* Copy context1 to the alternate signal stack area, because the
context1 allocated in the normal stack area is not accessible
from the signal handler that uses alternate signal stack. */
thiscontext = (ucontext_t *) ((new_sp - sizeof (ucontext_t)) & ~0xf);
memcpy (thiscontext, &context1, sizeof (ucontext_t));
new_sp = (uintptr_t) thiscontext;

/* In assembler: Save regs on new stack, move to alternate stack,
call thisfunc, revert stack regs. */
#ifdef __x86_64__
Expand Down Expand Up @@ -1850,6 +1857,7 @@ _cygtls::call_signal_handler ()
#else
#error unimplemented for this target
#endif
memcpy (&context1, thiscontext, sizeof (ucontext_t));
}
else
/* No alternate signal stack requested or available, just call
Expand Down
2 changes: 1 addition & 1 deletion winsup/cygwin/fhandler/pipe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ fhandler_pipe::set_pipe_buf_size ()
status = NtQueryInformationFile (get_handle (), &io, &fpli, sizeof fpli,
FilePipeLocalInformation);
if (NT_SUCCESS (status))
pipe_buf_size = fpli.InboundQuota;
pipe_buf_size = fpli.InboundQuota < PIPE_BUF ? PIPE_BUF : fpli.InboundQuota;
}

int
Expand Down
8 changes: 8 additions & 0 deletions winsup/cygwin/release/3.6.1
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ Fixes:

- Console mode is really restored to the previous mode.
Addresses: https://github.com/msys2/msys2-runtime/issues/268

- Clear direction flag in sigdeleyed before calling signal handler.
Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257704.html

- Copy context to alternate signal stack area in call_signal_handler()
in the SA_ONSTACK case, because locally-copied context on the normal
stack area is not accessible from the signal handler.
Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257714.html
1 change: 1 addition & 0 deletions winsup/cygwin/scripts/gendef
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ sigdelayed:
movq %rsp,%rbp
pushf
.seh_pushreg %rax # fake, there's no .seh_pushreg for the flags
cld # x86_64 ABI requires direction flag cleared
# stack is aligned or unaligned on entry!
# make sure it is aligned from here on
# We could be called from an interrupted thread which doesn't know
Expand Down