Age | Commit message (Collapse) | Author | Files | Lines |
|
Commit a942476236b5 ("Cygwin: sigdelayed: pop return address from
signal stack earlier") failed to take two facts into account:
- _cygtls::call_signal_handler() potentially needs the return address
as well, and
- the signal handler may be interrupted by another signal.
Revert the change in sigdelayed() and handle the signal stack manipulation
in _cygtls::call_signal_handler() instead.
Given we're poping the latest addresses from the signal stack early,
there's no need for a big signal stack anymore. Reduce the size of the
stack to 4 entries, plus one dummy entry. Move _cygtls::pop() from
assembler to C++ code and make sure that stackptr neither underflows nor
overflows the signal stack.
Fixes: a942476236b5 ("Cygwin: sigdelayed: pop return address from signal stack earlier")
Co-authored-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
The idea to define arc4random_stir() as macro to avoid autoconf
problems in commit a8891c932192 ("Cygwin: stdlib.h: resurrect
arc4random_stir() definition") worked fine for OpenSSH, but not
for libbsd. During the build process the macro shadows the
definition of arc4random_stir() and results in an error message
like this:
error: macro "arc4random_stir" passed 1 arguments, but takes just 0
Give up and just declare arc4random_stir() in a compatible way with
libbsd again.
Fixes: a8891c932192 ("Cygwin: stdlib.h: resurrect arc4random_stir() definition")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
When a signal handler is called via sigdelayed, sigdelayed pops
the original address to return to from the signal stack. It only
does so after the signal handler has been called and returned.
If the signal handler never returns, for instance because it calls
longjmp or setcontext, the address stays on the signal stack and
the stack loses one slot. Given the stack has a depth of 256 entries,
no signal handler will be called after 256 signal handlers long
jumping out.
Pop the return address from the signal stack prior to calling the
signal handler and store it in a callee-saved register. This avoids
filling up the signal stack in a scenario like this.
Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257648.html
Fixes: 61522196c715 ("* Merge in cygwin-64bit-branch.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
sigaction() returns EINVAL on SIGKILL & SIGSTOP. We need to skip them.
Fixes: c7c1a1ca1b33 ("* libc/posix/posix_spawn.c: New file.")
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
After return from a signal handler created with the SA_SIGINFO flag,
Cygwin checks if the handler changed the context. If so, Cygwin
erroneously uses the context in a call to setcontext().
Drop this special behaviour. Neither Linux man pages, nor POSIX
documentation treat the context pointer given to the handler as
anything other than a read-only area.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
This reverts commit c5f9eed1c045ad05e968c9a9b8fb22b1d46cd8ea.
This was the wrong thing to do because it leads to signal handling
not working after swapcontext.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
RtlCaptureContext always returnes a CONTEXT_FULL type context anyway.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
GetProcessGroupAffinity() requires PROCESS_QUERY_LIMITED_INFORMATION.
Fixes: 641ecb07533e ("Cygwin: Implement sched_[gs]etaffinity()")
Signed-off-by: Christian Franke <christian.franke@t-online.de>
|
|
The commit 3c1308ed890e adds a guard to stop signal handling on exit()
in call_signal_handler(). However, the signal that is already queued
but does not use signal handler may be going to process even with that
patch.
This patch add one more guard at the begining of sigpacket::process()
to avoid that situation.
Fixes: 3c1308ed890e ("Cygwin: signal: Fix a problem that process hangs on exit")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
|
When transferring huge file using scp, the "lost connection" error
sometimes happen. This is due to fhandler_pipe_fifo::raw_write()
accidentally sends data that is not reported in th return value when
interrupted by a signal. The cause of the problem is that CancelIo()
responds success even if NtWriteFile() already sends the data.
The following testcase using plain Win32 APIs reproduces the issue.
The output will be something like:
W: 8589934592
R: 9280061440
Much more data was received than the sender thought it had sent.
#include <windows.h>
#include <stdio.h>
DWORD WINAPI read_thread(LPVOID arg)
{
char buf[32768];
ssize_t sum = 0;
HANDLE pr = (HANDLE) arg;
while (1) {
DWORD nb;
BOOL res = ReadFile(pr, buf, sizeof(buf), &nb, NULL);
if (!res) break;
sum += nb;
}
printf("R: %lld\n", sum);
}
int main()
{
const char pipename[] = "\\\\.\\pipe\\testpipe";
char buf[65536*4] = {0,};
OVERLAPPED ov = {0,};
ssize_t sum = 0;
HANDLE pw = CreateNamedPipe(pipename,
PIPE_ACCESS_OUTBOUND | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE, 1, 65536, 0, 0, NULL);
HANDLE pr = CreateFile(pipename, GENERIC_READ, 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
HANDLE thr = CreateThread(NULL, 0, read_thread, pr, 0, NULL);
ov.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
int cnt = 0;
while (sum < 8192LL*1024*1024) {
DWORD nb;
BOOL res = WriteFile(pw, buf, sizeof(buf), &nb, &ov);
if (res) sum += nb;
else if (GetLastError() == ERROR_IO_PENDING) {
if ((cnt & 3) == 0) CancelIo (pw);
res = GetOverlappedResult(pw, &ov, &nb, TRUE);
if (!res && GetLastError() != ERROR_OPERATION_ABORTED) {
printf("%08x\n", GetLastError());
break;
}
sum += nb;
}
cnt++;
}
printf("W: %lld\n", sum);
CloseHandle(pw);
CloseHandle(ov.hEvenet);
WaitForSingleObject(thr, INFINITE);
CloseHandle(pr);
return 0;
}
It seems that CancelIo() works as expected when the NtWriteFile()
is stucked on the pipe full. If the writing is on-going, CancelIo()
reports cancelled, but the data may already be written.
To avoid this issue, this patch waits for completion of writing a
while before issuing CancelIo(), and if it has not completed yet,
call CancelIo().
The wait is done using existing cygwait(select_sem, 10, cw_cancel).
If the semaphore select_sem is released in the read side, the write
operation will be on-going. Otherwise, the write operation is still
stucking, so CancelIo() can safely cancel the I/O.
Addresses: https://cygwin.com/pipermail/cygwin/2025-January/257143.html
Fixes: 4003e3dfa1b9 ("Cygwin: pipes: always terminate async IO in blocking mode")
Reported-by: Jay M Martin <jaymmartin_buy@cox.net>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
|
setproctitle_init is defined in c2x manner, omitting names for
the unused parameters. This can result in warnings or errors
on certain compiler versions:
clang 8:
error: parameter name omitted
clang 15:
warning: omitting the parameter name in a function definition is a C2x
extension [-Wc2x-extensions]
gcc -Wsystem-headers -pedantic -std=c17:
warning: ISO C does not support omitting parameter names in function
definitions before C2X [-Wpedantic]
Add parameters to avoid above warning and errors.
Fixes: 2e7f7b96e5f1 ("Cygwin: implement setproctitle")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
An autoconf test for arc4random_stir() succeeds on Cygwin, because
we export the symbol for backward compatibility. However, when
building with -Werror afterwards, the definition of arc4random_stir()
is missing in the stdlib.h header, so there's a chance to encounter
an error like this with newer GCC:
sshd.c:1113:25: error: implicit declaration of function ‘arc4random_stir’; did you mean ‘arc4random_buf’? [-Wimplicit-function-declaration]
1113 | arc4random_stir();
| ^~~~~~~~~~~~~~~
| arc4random_buf
This occurs for instance when building OpenSSH 9.9p2 with GCC 15.0.
Define arc4random_stir() as an empty macro in cygwin/stdlib.h
to avoid the above compiler warning.
Do not define arc4random_addrandom() yet, in the hope that this function
call is really, really not used anymore.
Fixes: 1cca343e4714 ("Drop redundant arc4random prototypes from cygwin/stdlib.h")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
The process that receives many SIGSTOP/SIGCONT signals sometimes hangs
on exit in sig_dispatch_pending(). This patch skips processing signals
in call_signal_handler() when exit_state > ES_EXIT_STARTING to avoid
that situation.
Addresses: https://cygwin.com/pipermail/cygwin/2025-February/257473.html
Fixes: d243e51ef1d3 ("Cygwin: signal: Fix deadlock between main thread and sig thread")
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
|
The PID_STOPPED flag in _ponfo::process_state is sometimes accidentally
cleared due to a race condition when modifying it with the "|=" or "&="
operators. This patch uses InterlockedOr/And() instead to avoid the
race condition.
Addresses: https://cygwin.com/pipermail/cygwin/2025-February/257473.html
Fixes: 1fd5e000ace55 ("import winsup-2000-02-17 snapshot")
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
|
If SIGCONT starts processing while __SIGFLUSHFAST is ongoing,
_main_tls->current_sig will never be cleared because the signal
processing is stopped while waiting for the wake-up event in the
main thread. This leads to a deadlock in the while loop waiting for
current_sig to be cleared. With this patch, the function returns to
wait_sig() if current_sig is set, rather than waiting for it in the
while loop.
Addresses: https://cygwin.com/pipermail/cygwin/2025-February/257473.html
Fixes: 9d2155089e87 ("(sigpacket::process): Call handle_SIGCONT early to deal with SIGCONT.")
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
|
This patch fixes "integer overflow" warning in arc4random.c. It explicitly
casts REKEY_BASE macro to size_t. The existing code relies on an implicit
conversion to int and assumes that sizeof(int)=sizeof(size_t), which is
not always true.
2025-03-02 Jan Dubiec <jdx@o2.pl>
newlib/ChangeLog:
* libc/stdlib/arc4random.c (REKEY_BASE): Explicitly cast the macro
to size_t.
newlib/libc/stdlib/arc4random.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
This patch fixes a few "left shift count >= width of type
[-Wshift-count-overflow]" warnings. Before shifting a char 16 (or more)
bits left first it explicitly casts the char to uint32_t. The existing
code relies on implicit casts to int and assumes that ints are 32-bit.
This is not always true because the C standard does not require int to
be 32-bit and there are targets (e.g. H8/300) where by default int is
indeed 16-bit.
2025-03-02 Jan Dubiec <jdx@o2.pl>
newlib/ChangeLog:
* libc/stdlib/gdtoa-gdtoa.c (gdtoa): Cast to __ULong before left shift.
* libc/string/memmem.c (memmem): Cast to uint32_t before left shift.
* libc/string/strstr.c (strstr2): Ditto.
(strstr3): Ditto.
(strstr4): Ditto.
newlib/libc/stdlib/gdtoa-gdtoa.c | 2 +-
newlib/libc/string/memmem.c | 3 ++-
newlib/libc/string/strstr.c | 6 +++---
3 files changed, 6 insertions(+), 5 deletions(-)
|
|
2025-03-02 Jan Dubiec <jdx@o2.pl>
newlib/ChangeLog:
* libc/sys/h8300hms/sbrk.c: Replace the K&R definition with the
standard one.
* libc/sys/h8300hms/syscalls.c (_isatty): Ditto.
(_unlink): Ditto.
newlib/libc/sys/h8300hms/sbrk.c | 3 +--
newlib/libc/sys/h8300hms/syscalls.c | 6 ++----
2 files changed, 3 insertions(+), 6 deletions(-)
|
|
The required console mode for a non-cygwin process is different from
that for a cygwin process. There are currently three modes: tty::cygwin,
tty::native, and tty::restore. The latter two are for the non-cygwin
processes. tty::restore is the mode for the non-cygwin processes that
started the cygwin process, used to restore the previous behaviour.
tty::native is the mode that reflects some terminfo flags. The issue
below is caused because the console mode fails to be restored to the
previous console mode used by cmd.exe.
This patch redesigns the strategy to determine which mode should be
set on console close() to fix all similar problems. Previously, the
number of handle count is used to determine the appropriate console
mode. However, the handle count seems uncertain for that purpose.
In the new design, the relation ship between the master process and
the process that is about to close the console is mainly used. This
can provide more certain result than previous one.
Addresses: https://github.com/microsoft/git/issues/730
Fixes: 30d266947842 ("Cygwin: console: Fix clean up conditions in close()")
Reported-by: Mike Marcelais, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
While filenames on NFS shares are converted internally to a widechar
representation of the input bytes treated as the default system ANSI
codepage (CP_ACP), this doesn't hold for share names. The names
returned by WNetEnumResourceW are just the original bytes dropped
verbatim into WCHAR.
The original conversion from 7db1c6fc4e2a ("Cygwin: //server: revert
to using WNet and support NFS shares") was erroneous in that it
treated the bytes as ISO-8859-1, not as CP_ACP codepoints.
Fix the conversion to convert from CP_ACP to widechar. Use a tmp_pathbuf
buffer for the new widechar string instead of malloc/free. Extend the
comment, better explaining the encoding difference between files and
shares.
Fixes: 7db1c6fc4e2a ("Cygwin: //server: revert to using WNet and support NFS shares")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Fixes: b91d38db37d8 ("Cygwin: net: Make if_nametoindex, etc. consistent with if_nameindex.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
In the doc tree, add a new section "Other system interfaces[...]" that
lists the spawn family of functions, most of the exposed cygwin internal
functions that a user might have use for, and some other functions
duplicating Windows or DOS interfaces that might have some utility.
|
|
Some providers don't implement share enumeration. Allow to find
the server's connected resources in this case. Enable this feature
for the WNNC_NET_DAV provider.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
For some provider types, WNetGetResourceInformationW fails, namely
WNNC_NET_DAV. When that happens, try to find the server's provider
by enumerating all WNet containers from the top.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
- As before, first try NFS for dotted names, but additionally check if
the NFS profvider is installed.
- Next try *any* provider (i.e. provider = 0). Move the necessary
heuristics into thread_netdrive_wnet with lots of comments.
- Last, but not least, if the server was already tried for NFS,
but WNetGetResourceInformationW returns WNNC_NET_MS_NFS again
when trying any provider, bail out and retry with SMB, since
many NFS servers could be SMB servers as well.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
The nt_create() function returns a Windows error code, but
it only calls NT functions. In one case, it returns the
Windows error code without converting the NT status code
to a Windows error code first.
To fix this mess, change nt_create() to a function returning
the NT status code directly. Let the (only) caller handle
the conversion from NT status code to errno value.
Reported-by: "knut st. osmundsen" <bird-cygwin@anduin.net>
Fixes: f56206cd86b9 ("Cygwin: fhandler_pipe: fix permission problem")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
After 11a84cc757ef ("Cygwin: fix SSH hangs"), select returns
writability if any number of bytes are left in the buffer.
Thus, the reason for pipe_data_available() to return PIPE_BUF
when called from select() is gone, and we can drop special casing
select().
So together with 11a84cc757ef ("Cygwin: fix SSH hangs"), this
patch essentially reverts 555afcb2f3a6 ("Cygwin: select: set pipe
writable only if PIPE_BUF bytes left")
Rather than reverting the flag parameter to a bool, keep a mode
argument set to PDA_READ or PDA_WRITE. If we can't evaluate
the number of bytes left, just return 1 to select(), as for any
other caller.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
It was reported in https://github.com/git-for-windows/git/issues/5199
that as of v3.5.4, cloning or fetching via SSH is hanging indefinitely.
Bisecting the problem points to 555afcb2f3 (Cygwin: select: set pipe
writable only if PIPE_BUF bytes left, 2024-08-18). That commit's
intention seems to look at the write buffer, and only report the pipe as
writable if there are more than one page (4kB) available.
However, the number that is looked up is the number of bytes that are
already in the buffer, ready to be read, and further analysis
shows that in the scenario described in the report, the number of
available bytes is substantially below `PIPE_BUF`, but as long as they
are not handled, there is apparently a dead-lock.
Since the old logic worked, and the new logic causes a dead-lock, let's
essentially revert 555afcb2f3a6 ("Cygwin: select: set pipe writable only if
PIPE_BUF bytes left").
Note: This is not a straight revert, as the code in question has been
modified subsequently, and trying to revert the original commit would
cause merge conflicts. Therefore, the diff looks very different from the
reverse diff of the commit whose logic is reverted.
Fixes: 555afcb2f3a6 ("Cygwin: select: set pipe writable only if PIPE_BUF bytes left")
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
Signed-off-by: Christian Franke <christian.franke@t-online.de>
|
|
Fix the cygthread names used for debugging when calling the
thread_netdrive_wnet thread, so they actually show the provider
getting enumerated.
Fixes: 7db1c6fc4e2a ("Cygwin: //server: revert to using WNet and support NFS shares")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
So far there's no known way to enumerate connected WebDAV resources.
WNetGetResourceInformationW/WNetOpenEnumW both return ERROR_BAD_NET_NAME.
Windows Explorer also shows an error dialog when trying to open a
Nextcloud instance to see the shares.
However, `net use' enumerates the connected cloud shares, so
there must be a way to do this.
For the time being, we just don't even try to enumerate WebDAV
shares and return an empty list.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
WebDAV resources trigger the code trying to enumerate NFS shares
on the server. Disable this by checking for an at-sign as well.
Fixes: 8cebbb2b42bf ("Cygwin: fhandler_netdrive::exists: handle WebDAV URLs")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Combine multiple notes after an entry separated by hyphen ") (" -> " - "
Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
|
|
Fix some entries not in sorting order.
Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
|
|
Move entries no longer in POSIX from the SUS/POSIX section to
Deprecated Interfaces section and mark with (SUSv4).
Remove entries no longer in POSIX from the NOT Implemented section.
Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
|
|
Add unavailable POSIX additions to Not Implemented section.
Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
|
|
Add POSIX new additions available as header macros and inline functions,
or exported by Cygwin distro DLL or library packages
Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
|
|
new POSIX
Update anchor id and description to current version, year, issue, etc.
Move new POSIX entries in other sections to the SUS/POSIX section.
Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
|
|
WebDAV URLs may contain an at-sign followed by a port number or SSL.
This will throw GetAddrInfoW, so remove the at-sign prior to calling
GetAddrInfoW.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Add missing PID_MAP_RW to allow changes of _pinfo::sched_policy.
Fixes: 48b189245a13 ("Cygwin: sched_setscheduler: accept SCHED_OTHER, SCHED_FIFO and SCHED_RR")
Signed-off-by: Christian Franke <christian.franke@t-online.de>
|
|
Commit 8a8fb570d7c5310a03a34b3dd6f9f8bb35ee9f40 introduced a declaration
for "print", which conflicts with the incompatible declaration in
pru/putnumc.c.
Fix by removing the duplicate in pru/putnum.c, and rely on the
declaration in "glue.h".
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
|
|
This improves compatibility with clang that does not support vfpxd and does not need these extra directives.
Change-Id: Id2027e622aef8457ac9c7e1d6715a9240ce8e3f0
|
|
This is to improve compatibility with LLVM clang: .align 0 is a special case for GCC that is not handled by clang.
Change-Id: I855939a32294c74813ecce7275a362265dbc3b1a
|