aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-12-10Cygwin: path_conv: allow NULL handle in init_reopen_attr()Corinna Vinschen2-6/+3
init_reopen_attr() doesn't guard against a NULL handle. However, there are scenarios calling functions deliberately with a NULL handle, for instance, av::setup() calling check_file_access() only if opening the file did NOT succeed. So check for a NULL handle in init_reopen_attr() and if so, use the name based approach filling the OBJECT_ATTRIBUTES struct, just as in the has_buggy_reopen() case. Fixes: 4c9d01fdad2a ("* mount.h (class fs_info): Add has_buggy_reopen flag and accessor methods.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-09Cygwin: cygthread: add description for pty_master_fwd_threadCorinna Vinschen1-2/+2
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-08Cygwin: console: Ignore intermediate byte in CSI sequenceTakashi Yano1-0/+5
Recent vim throughs the sequence CSI '0%m' that cannot be handled appropriately by psuedo console for a test purpose. This patch removes the intermediate byte ('%') from the sequence. Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-12-08Cygwin: _cygtls: Remove _cygtls::spinningTakashi Yano4-8/+3
There seems to be no rationale reason for _cygtls::spinning to exist, so it has been removed. _cygtls::spinning was introduced in the commit edc4f86ad282A, and this flag means that another thread is waiting to acquire _cygtls::stacklock. It is checked in the sig thread in _cygtls:: interrupt_now(), and if spinning is true, the interrupt will be delayed. However, in this case, _cygtls::incyg is also set, so it is supposed to be covered by _cygtls::incyg flag and does not seem to add any value. If some problems happen in the signal handling, it might be a good idea to revert this commit and check if the issue will be fixed. Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-12-06Cygwin: cygthread: stop running all cygthreads at HIGHEST priority.Corinna Vinschen2-2/+4
Given the number of scenarios we're using cygthreads, it just doesn't make sense to run all of them with HIGHEST priority in preemptive obedience. Drop setting the cygthread priority and let the cygthreads decide by themselves. For the time being, run all cygthreads with normal priority. Change this locally in the thread function, if required. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-06Cygwin: cygthread: Add description of existing cygthreadsCorinna Vinschen1-0/+82
We're using the cygthread class in a considerable number of scenarios, but we don't keep track for which purposes we use them. Add a comment at the head of cygthread.cc to describe what cygthreads we maintain. This is supposed to be kept up-to-date if some cygthread is added, modified, or removed (wishful thinking). Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-06Cygwin: Document several fixes for signal handling in release noteTakashi Yano1-0/+4
2024-12-06Cygwin: signal: Introduce a lock for the signal queueTakashi Yano4-14/+32
Currently, the signal queue is touched by the thread sig as well as other threads that call sigaction_worker(). This potentially has a possibility to destroy the signal queue chain. A possible worst result may be a self-loop chain which causes infinite loop. With this patch, lock()/unlock() are introduce to avoid such a situation. Fixes: 474048c26edf ("* sigproc.cc (pending_signals::add): Just index directly into signal array rather than treating the array as a heap.") Suggested-by: Corinna Vinschen <corinna@vinschen.de> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-12-06Cygwin: signal: Remove queue entry from the queue chain when clearedTakashi Yano2-17/+34
The queue is cleaned up by removing the entries having si_signo == 0 while processing the queued signals, however, sigpacket::process() may set si_signo in the queue to 0 of the entry already processed but not succeed by calling sig_clear(). This patch ensures the sig_clear() to remove the entry from the queue chain. For this purpose, the pointer prev has been added to the sigpacket. This is to handle the following case appropriately. Consider the queued signal chain of: A->B->C->D without pointer prev. Assume that the pointer 'q' and 'qnext' point to C, and process() is processing C. If B is cleared in process(), A->next should be set to to C in sigpacket::clear(). Then, if process() for C succeeds, C should be removed from the queue, so A->next should be set to D. However, we cannot do that because we do not have the pointer to A in the while loop in wait_sig(). With the pointer prev, we can easily access A and C in sigpacket::clear() as well as A and D in the while loop in wait_sig() using the pointer prev and next without pursuing the chain. Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Fixes: 9d2155089e87 ("(wait_sig): Define variable q to be the start of the signal queue. Just iterate through sigq queue, deleting processed or zeroed signals") 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>
2024-12-05Cygwin: Add setjmp/longjmp fix to 3.5.5 release messagesCorinna Vinschen1-0/+3
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-05Cygwin: setjmp/longjmp: drop setting spinning flagCorinna Vinschen1-1/+0
Per the comment in _cygtls::interrupt_now(), the spinning flag is supposed to guard that the targeted thread is about to enter the Cygwin DLL. Setting spinning has then been added to _sigfe, _sigbe, sigdelayed and stabilize_sig_stack, the latter being called from setjmp/longjmp. However, setjmp/longjmp only enter the DLL in case of a pending signal, calling _cygtls::call_signal_handler(). This in turn is already guarded by setting the incyg flag, and there's no other action in stabilize_sig_stack which might interfere with the signal setup. All the rest of setjmp/longjmp is plain userspace. Therefore, drop setting the spinning flag from stabilize_sig_stack, because it results in dropped signals in tight longjmp loops. Fixes: edc4f86ad2827 ("* Makefile.in (clean): Remove sigfe.s.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-05Cygwin: cygtls: add volatile qualifier to spinningCorinna Vinschen1-1/+1
Given that spinning is only checked once at the start of a _cygtls::interrupt_now() which is called in a loop, it's probably not necessary to mark _cygtls::spinning as volatile. However, spinning is changed from assembler code and we don't want the compiler to make funny assumptions, so, better safe than sorry. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-05Cygwin: setjmp/longjmp: decrement incyg after signal handlingCorinna Vinschen1-0/+1
Commit 0b6fbd396ca2f ("* exceptions.cc (_cygtls::interrupt_now): Revert to checking for "spinning" when choosing to defer signal.") introduced a bug in the loop inside the stabilize_sig_stack subroutine: First, stabilize_sig_stack grabs the stacklock. The _cygtls::incyg flag is then incremented before checking if a signal has to be handled for the current thread. If no signal waits, the code simply jumps out, decrements _cygtls::incyg and returns to the caller, which eventually releases the stacklock. However, if a signal is waiting, stabilize_sig_stack releases the stacklock, calls _cygtls::call_signal_handler(), and returns to the start of the subroutine, trying to grab the lock. After grabbing the lock, it increments _cygtls::incyg... wait... again? The loop does not decrement _cygtls::incyg after _cygtls::call_signal_handler(), which returns with _cygtls::incyg set to 1. So it increments incyg to 2. If no other signal is waiting, stabilize_sig_stack jumps out and decrements _cygtls::incyg to 1. Eventually, setjmp or longjmp both will return to user code with _cygtls::incyg set to 1. This *may* be fixed at some later point when signals arrive, but there will be a time when the application runs in user code with broken signal handling. Fixes: 0b6fbd396ca2f ("* exceptions.cc (_cygtls::interrupt_now): Revert to checking for "spinning" when choosing to defer signal.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-05libm/common: Fix nextafter and nextafterf when x == yKito Cheng2-2/+2
That according to C99/POSIX, nextafter(x,y) should return y if x==y. [1] NetBSD fix for this: https://github.com/IIJ-NetBSD/netbsd-src/commit/3bc685224189d2b7dfb68da52d9725a256a667bd [2] glibc fix for this: https://github.com/bminor/glibc/commit/bc9f6000f6752153e5e1902259d5f491a88a1ae5#diff-bcc0628a39c3c2003047dcb5a40a8b50c00f01a74b1c8c1100d770a8e48b1ce2 [3] Linux man page: https://man7.org/linux/man-pages/man3/nextafter.3.html
2024-12-04Cygwin: try_to_bin: transpose deleted file name to valid Unicode charsCorinna Vinschen2-5/+8
Since commit 314c2d2fedc5f ("* syscalls.cc (try_to_bin): Handle remote shares as well.") try_to_bin() transposes the .cyg prefix for temporary files to invalid low surrogate halfs on filesystems setting the FILE_UNICODE_ON_DISK flag. This works on NTFS, but not necessarily on other filesystems, which often require all chars in a filename to be valid Unicode chars. Fix this by transposing into the private use area instead. Fixes: 314c2d2fedc5f ("* syscalls.cc (try_to_bin): Handle remote shares as well.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-04Cygwin: sched_setscheduler: accept SCHED_IDLEChristian Franke3-6/+17
Add SCHED_IDLE to <sys/sched.h>. If SCHED_IDLE is selected, preserve the nice value and set the Windows priority to IDLE_PRIORITY_CLASS. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-12-04Cygwin: doc: document sched_setpolicy(2) and priority mappingChristian Franke1-4/+30
Document the long standing mapping from nice or sched_priority values to Windows priority classes and the new behavior of sched_setpolicy(8). Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-12-04Cygwin: sched_setscheduler: accept SCHED_OTHER, SCHED_FIFO and SCHED_RRChristian Franke9-63/+118
If SCHED_OTHER is selected, set the Windows priority according to the nice value. If SCHED_FIFO or SCHED_RR is selected, preserve the nice value and set the Windows priority according to the sched_priority parameter. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-12-04Cygwin: Fix compatibility with GCC 15Radek Bartoň17-106/+116
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
2024-12-04Cygwin: drop unnecessary inclusion of spinlock.hCorinna Vinschen2-2/+0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-04Cygwin: termios: Trim buffer size for GetConsoleProcessList()Takashi Yano2-2/+15
Currently, the buffer of 128KB is passed to GetConsoleProcessList(). This causes page fault in the select() loop for console due to: https://github.com/microsoft/terminal/issues/18264 because the previous code calls GetConsoleProcessList() with large buffer and PeekConsoleInput() with small buffer alternately. With this patch, the minimum buffer size is used that is determined by GetConsoleProcessList() with small buffer passed. Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256841.html Fixes: 72770148ad0a ("Cygwin: pty: Prevent pty from changing code page of parent console.") Reported-by: Steven Buehler <buehlersj@outlook.com> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-12-03Change various declarations to ANSI style to avoid problems with gcc 15Radek Barton14-358/+468
2024-12-04Cygwin: signal: Increase chance of handling signal in main threadTakashi Yano1-1/+4
If the process() fails and the signal remains in the queue, the most possible reason is that the target thread is already armed by another signal and does not handle it yet. With this patch, to increase the chance of handling it in the other threads, call yield() before retrying process(). Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Fixes: e10f822a2b39 ("Cygwin: signal: Handle queued signal without explicit __SIGFLUSH") Reported-by: Christian Franke <Christian.Franke@t-online.de> Reviewed-by: Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-12-04Cygwin: signal: Optimize the priority of the sig threadTakashi Yano1-0/+1
Previously, the sig thread ran in THREAD_PRIORITY_HIGHEST priority. This causes a critical delay in the signal handling in the main thread if too many signals are received rapidly and the CPU is very busy. In this case, most of the CPU time is allocated to the sig thread, so the main thread cannot have a chance of handling signals. With this patch, to avoid such a situation, the priority of the sig thread is set to THREAD_PRIORITY_NORMAL priority. Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Fixes: 53ad6f1394aa ("(cygthread::cygthread): Use three only arguments for detached threads, and start the thread via QueueUserAPC/async_create.") 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>
2024-12-03Cygwin: signal: Fix a short period of deadlockTakashi Yano1-1/+2
The main thread waits for the sig thread to read the signal pipe by calling Sleep(10) if writing to the signal pipe has failed. However, if the signal thread waiting for another signal being handled in the main thread, the sig thread does not read the signal pipe. To avoid such a situation, this patch replaces Sleep(10) to cygwait(). Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Fixes: 6f05b327678f ("(sig_send): Retry WriteFiles which fail when there is no error but packbytes have not been sent.") 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>
2024-12-03Cygwin: cygtls: Prompt system to switch tasks explicitly in lock()Takashi Yano2-40/+15
This patch calls Sleep(0) in the wait loop in lock() to increase the chance of being unlocked in other threads. The lock(), unlock() and locked() are moved from sigfe.s to cygtls.h so that allows inline expansion. Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Fixes: 61522196c715 ("* Merge in cygwin-64bit-branch.") 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>
2024-12-02Cygwin: setpriority, sched_setparam: add missing process access rightChristian Franke3-3/+8
set_and_check_winprio() also requires PROCESS_QUERY_LIMITED_INFORMATION. Also add an early check for this access right to set_and_check_winprio(). Fixes: 153b51ee08ef ("Cygwin: setpriority, sched_setparam: fail if Windows sets a lower priority") Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-11-29Cygwin: fcwd_access_t::SetVersionFromPointer: drop declarationCorinna Vinschen1-1/+0
This method has been removed when we stopped supporting older Windows versions and only one supported FAST_CWD structure remained. Belatedly drop the declaration as well. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-11-28Cygwin: uname: add host machine tag to sysname.Jeremy Drake1-2/+16
If the Cygwin dll's architecture is different from the host system's architecture, append an additional tag that indicates the host system architecture (the Cygwin dll's architecture is already indicated in machine). Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2024-11-28Cygwin: cache IsWow64Process2 host arch in wincap.Jeremy Drake3-4/+25
This was already used in the FAST_CWD check, and could be used in a couple other places. I found the "emulated"/process value returned from the function largely useless, so I did not cache it. It is useless because, as the docs say, it is set to IMAGE_FILE_MACHINE_UNKNOWN (0) if the process is not running under WOW64, but Microsoft also doesn't consider x64-on-ARM64 to be WOW64, so it is set to 0 regardless if the process is ARM64 or x64. You can tell the difference via GetProcessInformation(ProcessMachineTypeInfo), but for the current process even that's overkill: what we really want to know is the IMAGE_FILE_MACHINE_* constant for the Cygwin dll itself, which is conveniently located in memory already, so cache that in wincap also for easy comparisons. Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2024-11-28Cygwin: nice: align return value and errno with POSIX and LinuxChristian Franke2-1/+14
Return new nice value instead of 0 on success. Set errno to EPERM instead of EACCES on failure. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-11-28Cygwin: signal: Fix another deadlock between main and sig threadTakashi Yano2-4/+10
In _cygtls::handle_SIGCONT(), the sig thread waits for the main thread to process the signal without unlocking the TLS area. This causes a deadlock if the main thread tries to acquire a lock for the TLS area in the meantime. With this patch, unlock the TLS before calling yield() in handle_SIGCONT(). Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Fixes: 26158dc3e9c2("* exceptions.cc (sigpacket::process): Lock _cygtls area of thread before accessing it.") 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>
2024-11-28Cygwin: signal: Drop unnecessary queue flushTakashi Yano1-1/+1
Previously, the retry flag was always set when pending_signal::pending() was called. However, if the queue is empty sig thread tries to flush the queue even though it is not necessary. With this patch, the retry flag is set only if the queue is not empty. Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Fixes: 5e31c80e4e8d ("(pending_signals::pending): Force an additional loop through wait_sig by setting retry whenever this function is called.") 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>
2024-11-28Cygwin: signal: Handle queued signal without explicit __SIGFLUSHTakashi Yano1-0/+3
With the previous code, the queued signal is tried to resend only when a new signal arrives or pending_signals::pending() is called. With this patch, if the signal is queued and the retry flag is not set and the new signal is not received yet, the sig thread tries to handle the queued signal again. Without this patch, the chance to handle the queue would be delayed. Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Fixes: 5e31c80e4e8d ("(pending_signals::pending): Force an additional loop through wait_sig by setting retry whenever this function is called.") 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>
2024-11-28Cygwin: signal: Fix deadlock between main thread and sig threadTakashi Yano1-1/+1
Previously, a deadlock happened if many SIGSTOP/SIGCONT signals were received rapidly. If the main thread sends __SIGFLUSH at the timing when SIGSTOP is handled by the sig thread, but not is handled by the main thread yet (sig_handle_tty_stop() not called yet), and if SIGCONT is received, the sig thread waits for cygtls::current_sig (is SIGSTOP now) cleared. However, the main thread waits for the pack.wakeup using WaitForSingleObject(), so the main thread cannot handle SIGSTOP. This is the mechanism of the deadlock. This patch uses cygwait() instead of WaitForSingleObject() to be able to handle the pending SIGSTOP. Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Fixes: 7759daa979c4 ("(sig_send): Fill out sigpacket structure to send to signal thread rather than racily sending separate packets.") 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>
2024-11-27Cygwin: sched_setscheduler: allow changes of the priorityChristian Franke2-1/+7
Behave like sched_setparam() if the requested policy is identical to the fixed value (SCHED_FIFO) returned by sched_getscheduler(). Fixes: 9a08b2c02eea ("* sched.cc: New file. Implement sched*.") Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-11-27Cygwin: setpriority, sched_setparam: fail if Windows sets a lower priorityChristian Franke5-3/+38
Windows silently sets a lower priority than requested if the new priority requires administrator privileges. Revert to previous priority and fail with EACCES or EPERM in this case. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-11-27Cygwin: sched_getscheduler: fix error handlingChristian Franke1-1/+4
Fixes: 6b2a2aa4af1e ("Add missing files.") Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-11-25Cygwin: revert use of CancelSyncronousIo on wait_thread.Jeremy Drake2-17/+5
It appears this is causing hangs on native x86_64 in similar scenarios as the hangs on ARM64, because `CancelSynchronousIo` is returning `TRUE` but not canceling the `ReadFile` call as expected. Addresses: https://github.com/msys2/MSYS2-packages/issues/4340#issuecomment-2491401847 Fixes: b091b47b9e56 ("cygthread: suspend thread before terminating.") Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2024-11-23Cygwin: cygtls: rename sig to current_sigCorinna Vinschen6-18/+20
The currently handled signal in a thread is called _cygtls::sig. The variable name "sig" is used pretty often in the Cygwin source. This makes it tricky to distinguish the currently handled signal from any other usage of "sig". Therefore, rename _cygtls::sig to _cygtls::current_sig Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-11-23Cygwin: gendef: unify comments in terms of acquiring/releasing stacklockCorinna Vinschen1-14/+14
Various forms of describing what we do with the stacklock are used. Try to be consistent. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-11-22Cygwin: sigtimedwait: Fix segfault when timeout is usedTakashi Yano3-1/+19
Previously, two bugs exist in sigtimedwait(). One is, that since _my_tls.sigwait_mask was left non-zero if the signal arrives after the timeout, sigpacket::process() would wrongly try to handle it. The other is if a timeout occurs after sigpacket::process() is called, but not completed yet, the signal handler can be called accidentally. If the signal handler is set to SIG_DFL or SIG_IGN, access violation will occur in both cases. With this patch, in sigwait_common(), check if sigwait_mask == 0 to confirm that sigpacket::process() cleared it. In this case, do not treat WAIT_TIMEOUT, but call cygwait() again to retrieve the signal. Furthermore, sigpacket::process() checks whether timeout occurs in sigwait_common() and if timeout already happens, do not treat the signal as waited. In both cases, to avoid race issues, the code is guarded by cygtls::lock(). Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256762.html Fixes: 24ff42d79aab ("Cygwin: Implement sigtimedwait") 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>
2024-11-20Cygwin: SetThreadName: avoid spurious debug messageCorinna Vinschen1-1/+1
The following debug message occassionally shows up in strace output: SetThreadName: SetThreadDescription() failed. 00000000 10000000 The HRESULT of 0x10000000 is not an error, rather the set bit just indicates that this HRESULT has been created from an NTSTATUS value. Use the IS_ERROR() macro instead of just checking for S_OK. Fixes: d4689b99c686 ("Cygwin: Set threadnames with SetThreadDescription()") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-11-20Cygwin: flock: Fix overlap handling in lf_setlock() and lf_clearlock()Takashi Yano2-13/+21
Currently, create_lock_obj() can create multiple locks with the same lock range that have different version number. However, lf_setlock() and lf_clearlock() cannot handle this case appropriately. With this patch, make lf_setlock() and lf_clearlock() find overlap again even when ovcase = 1 (lock and overlap have the same lock range). Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256750.html Fixes: 2e560a092c1c ("* flock.cc (LOCK_OBJ_NAME_LEN): Change to accommodate extra lf_ver field.") Reported-by: Sebastian Feld <sebastian.n.feld@gmail.com> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-11-20Cygwin: lockf: Fix access violation in lf_clearlock().Takashi Yano2-2/+7
The commit ae181b0ff122 has a bug that the pointer is referred bofore NULL check in the function lf_clearlock(). This patch fixes that. Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256750.html Fixes: ae181b0ff122 ("Cygwin: lockf: Make lockf() return ENOLCK when too many locks") Reported-by: Sebastian Feld <sebastian.n.feld@gmail.com> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-11-20Remove accidental checkin of top-level file "test"Corinna Vinschen1-71/+0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-11-20newlib/libc/include/time.h: Removed clock_id castsAaron Nyholm2-10/+81
The POSIX specification defines these as constants. The cast is unnecessary. This brings newlib inline with the equivalent FreeBSD defines.
2024-11-20cygthread: suspend thread before terminating.Jeremy Drake3-5/+31
This addresses an extremely difficult to debug deadlock when running under emulation on ARM64. A relatively easy way to trigger this bug is to call `fork()`, then within the child process immediately call another `fork()` and then `exit()` the intermediate process. It would seem that there is a "code emulation" lock on the wait thread at this stage, and if the thread is terminated too early, that lock still exists albeit without a thread, and nothing moves forward. It seems that a `SuspendThread()` combined with a `GetThreadContext()` (to force the thread to _actually_ be suspended, for more details see https://devblogs.microsoft.com/oldnewthing/20150205-00/?p=44743) makes sure the thread is "booted" from emulation before it is suspended. Hopefully this means it won't be holding any locks or otherwise leave emulation in a bad state when the thread is terminated. Also, attempt to use `CancelSynchonousIo()` (as seen in `flock.cc`) to avoid the need for `TerminateThread()` altogether. This doesn't always work, however, so was not a complete fix for the deadlock issue. Addresses: https://cygwin.com/pipermail/cygwin-developers/2024-May/012694.html Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2024-11-19Add Windows Server 2025 build numberDavid Warner1-0/+2
Signed-off-by: David Warner <david@warnr.net>
2024-11-19Add libaio to SUBLIBS built for CygwinMark Geisert2-1/+8
Provide libaio.a for those projects (such as stress-ng) checking for POSIX aio support by looking for this library at configure time. A release note is provided for Cygwin 3.6.0. Signed-off-by: Mark Geisert <mark@maxrnd.com> Fixes: N/A (new code)