Deadlocks have been observed if the message queue functions are called
from different threads in the same process.
Remove incorrectly locking the descriptor table while accessing the
message queue fhandler, potentially calling blocking functions.
Fixes: 46f3b0ce85a9 ("Cygwin: POSIX msg queues: move all mq_* functionality into fhandler_mqueue")
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit fe6ddc15a35636ca7027c32e4c60ebb136fc9d7f)
Message queues are basically just files and in most cases can be handled
like normal files. So it was a mistake to set the "on-disk-device" flag
for them to fix the mq_unlink() problem reported in
https://cygwin.com/pipermail/cygwin/2025-January/257119.html
Rather, given that unlink() just checks if the object to be deleted
has an on-disk representation, make sure message queues are added to
the path_conv::isondisk() predicate.
This also reverts commit d870655f570f25393dcefbaf0b1dc807f277749c.
Fixes: d870655f570f ("Cygwin: path_conv: set on-disk-device flag for message queue files")
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit b940faa144cae9cd29295d8fdaac163a17f334cc)
Checking EPERM only makes sense if the file exists, so
let the EEXIST check change places with the EPERM check.
Add a debug statement to the EPERM condition.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit b879cd1661ad2fb37f603e18f6b1860c91f445ec)
Some checks in path_conv are checking for various properties
to generate a boolean value, mostly to indicate different
combinations of on-disk files and devices.
Simplify these checks and, especially, document them inline.
Drop the isdevice() check in favor of a new isondisk() check.
Fixes: 4fc922b2c8a5 ("Cygwin: POSIX msg queues: Convert mqd_t to a descriptor")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit 890086ad3704fc1aaedca96d3bf67448e7a66775)
This simplifies further checks for on-disk-devices in places with
special handling for such files.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit d870655f570f25393dcefbaf0b1dc807f277749c)
The debug statement supposed to be printed when deleting with POSIX
semantics failed with STATUS_CANNOT_DELETE or STATUS_INVALID_PARAMETER
is in the wrong spot. While at it, simplify the related comment.
Fixes: 9fa22dba558f ("Cygwin: unlink: allow fallback from POSIX to default method")
Fixes: 527dd1b407e7 ("Cygwin: fix unlink in container")
Fixes: 87ab6c7b26bf ("Cygwin: log disabling posix semantics")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit bf94b87f54de862a1c2482d411a18973b29264fe)
Commentary wording now refers to tasks (i.e., threads) rather than
processes. This makes it somewhat easier to justify adding two kinds of
counters together. After researching what "load average" has meant over
time, we have what seems like a reasonable implementation, modulo
Windows differences to Linux. The best resource I found is:
https://www.brendangregg.com/blog/2017-08-08/linux-load-averages.html
At end of load_init(), obtain and discard the first measure of the
counters to deal with the first call always returning error, no data.
Follow this with a specific short delay so the next measure actually has
data to report.
At least one older version of Windows, i.e. Win10 Pro 21H1, has a different
name/location for the '% Processor Time' counter and is missing the
'Processor Queue Length' counter entirely. Code is changed to support
both possible locations of the former and treat the missing latter as always
reporting 0.0.
A release note is added for 3.5.6.
Reported-by: Mark Liam Brown <brownmarkliam@gmail.com>
Addresses: https://cygwin.com/pipermail/cygwin/2024-August/256361.html
Signed-off-by: Mark Geisert <mark@maxrnd.com>
Fixes: 4dc982ddf60b (Cygwin: loadavg: improve debugging of load_init)
(cherry picked from commit 0135b94949d2c9ba0b0f839fae8ff49a5bfe8589)
It seems that current _cygtls::handle_SIGCONT() code sometimes falls
into a deadlock due to frequent TLS lock/unlock operation in the
yield() loop. With this patch, the yield() in the wait loop is placed
outside the TLS lock to avoid frequent TLS lock/unlock.
Fixes: 9ae51bcc51a7 ("Cygwin: signal: Fix another deadlock between main and sig thread")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Validate the fd returned by cygheap_getfd operating on given mqd.
A release note is provided for 3.5.6.
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Addresses: https://cygwin.com/pipermail/cygwin/2025-January/257090.html
Signed-off-by: Mark Geisert <mark@maxrnd.com>
Fixes: 46f3b0ce85a9 (Cygwin: POSIX msg queues: move all mq_* functionality into fhandler_mqueue)
(cherry picked from commit 9a4a44523bb71e1fd453cdebe2182c9ab913a222)
The commit a22a0ad7c4f0 was not entirely correct. Even with the patch,
some hangs still occur. This patch overrides the previous commit along
with the patch that makes cygwait() reentrant, to fix these hangs.
Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256954.html
Fixes: d243e51ef1d3 ("Cygwin: signal: Fix deadlock between main thread and sig thread")
Reported-by: Daisuke Fujimura <booleanlabel@gmail.com>
Reviewed-by: Corinna Vinschen <corinna@vinshcen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
(cherry picked from commit 83afe3e238cd12fb7d4799ba6b3c77e9e3618d91)
To allow cygwait() to be called in the signal handler, a locally
created timer is used instead of _cygtls::locals.cw_timer if it is
in use.
Co-Authored-By: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
(cherry picked from commit ea1914000adcbed5c16fc0ba2676173b2f6016c4)
Use "Cygwin Setup program" and add a link to the homepage in some
cases.
Reported-by: David Dyck <david.dyck@gmail.com>
Reviewed-by: Jon Turney <jon.turney@dronecode.org.uk>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit 4adb6c380659c6f74f7971ceb93c82558331f74a)
When Microsoft started to claim the "sshd" service name, we had
to rename our service to "cygsshd" but we never updated the docs.
Make sure the docs reflect the changed service name and fix a
few bumpy expression.
Reported-by: Mario Emmenlauer <mario@emmenlauer.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit d21eb90bbcadb30a00abf59dd64375601c108f96)
This FAQ entry has been commented out for quite some time.
Drop it.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit 37ed066c5f76d179c83342a816d72f996a8af3d2)
unlink_nt() and rename2 () both check for the FILE_SUPPORTS_OPEN_BY_FILE_ID
flag to use POSIX delete/rename semantics. Both erroneously check the flag
against the file attributes using has_attributes().
Given that this flag is a filesystem flag, check using fs_flags() instead.
Fixes: fe2545e9faaf ("Cygwin: don't use unlink/rename POSIX semantics on certain NTFS")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit 264544bf72f6ed85530a1b058e9efdb73ab72e90)
After commit a0933cd17d19, access(_, X_OK) returns 0 if the user
holds SE_BACKUP_PRIVILEGE, even if the file's ACL denies execution
to the user. This is triggered by trying to open the file with
FILE_OPEN_FOR_BACKUP_INTENT.
Fix check_file_access() so it checks for X_OK without specifying
the FILE_OPEN_FOR_BACKUP_INTENT flag if the file is not a directory.
Rearrange function slightly and add comments for easier comprehension.
Fixes: a0933cd17d19 ("Cygwin: access: Correction for samba/SMB share")
Reported-by: Bruno Haible <bruno@clisp.org>
Co-authored-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit 2e4db338ac125579d555aeee516e48588a628a16)
In testing whether the requested area is contained in an existing
mapped region, an incorrect condition was used due to a
misinterpretation of the u_addr and u_len variables.
Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256913.html
Fixes: c68de3a262fe5 ("* mmap.cc (class mmap_record):
Declare new map_pages method with address parameter.")
Signed-off-by: Ken Brown <kbrown@cornell.edu>
(cherry picked from commit 67bef16f7edf8642366ff55399bf9cf007c66d52)
Previously, when unused pages from an mmap_record were recycled, they
were given the protection of the mmap_record rather than the
protection requested in the mmap call. Fix this by adding a
"new_prot" parameter to mmap_list::try_map() and
mmap_record::map_pages() to keep track of the requested protection.
Then use new_prot in the calls to VirtualProtect().
Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256911.html
Fixes: f90e23f2714cb ("*autoload.cc (NtCreateSection): Define.")
Signed-off-by: Ken Brown <kbrown@cornell.edu>
(cherry picked from commit 677e3150907a83f17e50d546f79b7ca863ebd77d)
The commit e10f822a2b39 has a problem that CPU load gets high if
pending signal is not processed successfully for a long time.
With this patch, wait_sig() calls Sleep(1), rather than yield(),
if the pending signal has not been processed successfully for a
predetermined time to prevent CPU from high load.
Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256884.html
Fixes: e10f822a2b39 ("Cygwin: signal: Handle queued signal without explicit __SIGFLUSH")
Reported-by: 凯夏 <walkerxk@gmail.com>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
(cherry picked from commit 1d1451ccd2a6c0f0146ddee68f386061b69863c0)
Previously, access() and eaccess() does not determine the permissions
for files on samba/SMB share correctly. Even if the user logs-in as
the owner of the file, access() and eaccess() referes to others'
permissions. With this patch, to determine the permissions correctly,
NtOpenFile() with desired access mask is used.
Fixes: cf762b08cfb0 ("* security.cc (check_file_access): Create.")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
(cherry picked from commit a0933cd17d19cca72b972a248e70210152f06808)
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>
(cherry picked from commit 815eba882e32ecadd6862c71c36fccdcb0842a76)
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>
(cherry picked from commit 496fa7b2ce0052550eab8900723ebb59c33d25e7)
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>
(cherry picked from commit d565aca46f06117ef16ec37c51767a5e140ee9e2)
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>
(cherry picked from commit 96d856320a1d740546eaf8a6c0ddb3d489e10492)
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>
(cherry picked from commit 3a9fb7c561d9e8a78e444dd3920c57e857a92baa)
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>
(cherry picked from commit 41e1013e6846f1774dfec085ff983990f67e6437)
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>
(cherry picked from commit c48d58d838d90df6247123c487686699742d75de)
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>
(cherry picked from commit 9a274a967d1fe9a28d0d658749b08e65d09d3ee0)
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>
(cherry picked from commit 2544e753963e9c15a9e3fe35188d8dea7b39d748)
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>
(cherry picked from commit 9b7a84d24aa17bdd727eb402cc544fa36f4d812e)
Various forms of describing what we do with the stacklock are
used. Try to be consistent.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit 63804a28b330ccda7e1ef1c04d2d1c5e22a8e40d)
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>
(cherry picked from commit 9ae51bcc51a7901559c476e6301597760c2726fd)
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>
(cherry picked from commit 57ce5f1e0bf4a6fef7173b2549edc4f2090dd0e7)
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>
(cherry picked from commit e10f822a2b39bade20858ba3c704a8bb7d965cb4)
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>
(cherry picked from commit d243e51ef1d30312ba1e21b4d25a1ca9a8dc1f63)
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>
(cherry picked from commit 0924d5f1078b368b6e290d11c9f3d57bc7767576)
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>
(cherry picked from commit 1a49c17840660bc0e493b7db2d9ce5289906049d)
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>
(cherry picked from commit 522f3e921aa034c6a146021a918ce8b479a9111e)
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>
(cherry picked from commit 26144e4008cd8f7288f3387eea697bba4006e16f)
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>
(cherry picked from commit 21a2c9db6952954608cdf92638b411b15e7606c6)
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>
(cherry picked from commit 8dee07a1f12682307be07e12a7fd8d5c8ecc1e2b)