| Age | Commit message (Collapse) | Author | Files | Lines |
|
The loop at line 50 should test the bytes in the buffer, from the end
towards the beginning, until it reaches a character whose address is
aligned, leaving `src' pointing to the next character to test. However,
the loop condition did not test the address of the last character read
(`src + 1'), but the address of the next character (`src'). As a
consequence, a misaligned address was computed at line 69, because the
(aligned) address in `src' is incremented by 1.
This bug was originally introduced in commit c9b74e328 during a
refactoring of the macros used by string functions. Before the
refactoring, the +1 increment in the loop condition was located in the
macros specific to memrchr.
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
This is a port of e3a4f13 commit from Picolibc. Here is an
original explanation for this patch:
This code accesses memory up to 7 bytes before the argument
which causes access faults on targets with stack bounds
checking enabled. Instead of attempting to fix it, just use
the C version on all targets which is nearly as fast for this
operation.
Indeed, this implementation is not safe.
Co-authored-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
|
|
Building of C++ applications may fail without this stub if
libraries are not built with -ffunction-sections.
Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
|
|
An optimized version of strchr for ARC Classic is incompatible
with targets with 16-entry register file.
Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
|
|
Previously, results that should have rounded up to the minimum
magnitude floating-point value would instead return zero, in
round-to-nearest-even mode. E.g. scalbnf(0x1.000002p0,-150) with
subnormal support of scalbnf(0x1.000002p0,-127) without.
* newlib/libm/common/fdlibm.h (FLT_SMALLEST_EXP): Adjust down by one.
Adjust documentation.
|
|
Don't build long double newlib/libm for Windows on aarch64 as
newlib/libm supports only 80bit or 128bit long doubles, while
aarch64 Windows uses 64bit long doubles.
Exclude aarch64-*-mingw* and aarch64-*-cygwin* targets from
HAVE_FPMATH_H conditional to prevent building 128-bit long
double math functions (ld128), which are incompatible with
these platforms' 64bit long double representation.
Signed-off-by: Martin Vejbora <martin.vejbora@microsoft.com>
Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
|
|
For a very long time, since 2011 or earlier, fork() has printed an internal
error message when it fails due to a CreateProcess() error. This patch
quashes the error message as far as the user can tell, but it will still be
present in an strace.
This change is a judgement call based on the fact we now support
RLIMIT_NPROC and so a user limiting the number of subprocesses may hit
more CreateProcess() errors by design. Don't clutter the scene.
Fixes: 855108782321 (* dll_init.c (dll_list::load_after_fork): Don't
clear in_forkee here.)
Signed-off-by: Mark Geisert <mark@maxrnd.com>
|
|
Fixes: 74594f33e030 (Cygwin: add resource limit changes to release notes)
Signed-off-by: Mark Geisert <mark@maxrnd.com>
|
|
Currently, the following command in bash cannot make `cat | cmd`
foreground correctly, and also cannot be terminated by Ctrl-C.
$ cat |cmd &
$ fg
$ (Ctrl-C)
This is because, bash does not recognize the process `cmd` as stopped
by SIGTTIN, and does not send SIGCONT not only to `cmd` but also to
`cat`.
To solve this problem, this patch implements fake stop/cont for non-
cygwin process such as `cmd`. Even with this patch, the process `cmd`
does not enter into stopped state because non-cygwin process itself
does not handle cygwin signal, but the stub process for `cmd` enters
into stopped state instead by SIGTTIN.
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Waiting for `sendsig` to be non-zero for non-cygwin process is
pointless, because it never becomes non-zero (see spawn.cc).
Do not wait `sendsig` for a non-cygwin process.
Fixes: d584454c8231 ("* sigproc.cc (sig_send): Wait for dwProcessId to be non-zero as well as sendsig.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
|
|
The current code waits for `sendsig` by `for` loop in sigproc.cc,
however, the wait time might be insufficient for recent CPU.
The current code is as follows.
for (int i = 0; !p->sendsig && i < 10000; i++)
yield ();
Due to this problem, in tcsh, the following command occasionally
cannot be terminated by Ctrl-C. This is because, SIGCONT does not
wake-up `sleep` process correctly.
$ cat | sleep 100 &
$ fg
$ (type Ctrl-C)
With this patch, the wait time for `sendsig` is guaranteed to be
up to 100ms instead of looping for 10000 times.
Fixes: d584454c8231 ("* sigproc.cc (sig_send): Wait for dwProcessId to be non-zero as well as sendsig.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
While testing the new rlimit implementation, it was noticed fork()
returns an EIO error on hitting the process count limit. Per POSIX,
the error should be EAGAIN. This patch makes the change.
Along the way it was noticed Windows ERROR_DISK_QUOTA_EXCEEDED was not
being mapped to any POSIX error. This patch changes the mapping to EFBIG.
Addresses: https://cygwin.com/pipermail/cygwin-patches/2026q1/014707.html
Signed-off-by: Mark Geisert <mark@maxrnd.com>
Fixes: c2f6c0415501 (Cygwin: errmap[]: update comments using current winerror.h)
|
|
The check is now subsumed into setup_user_rlimits().
Perform the check only if we're the root process of a Cygwin process
tree. If we start mintty from Cygwin, the PCA trigger doesn't occur.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Implement RLIMIT_NPROC by creating per-user job objects. Those
are not auto-breakaway. Only breakaway explicitely from per-user jobs
if we change the user context in child_info_spawn::worker(). Only
then the real uid changes and the new child has to be assigned to
the per-user job objects for the new real uid.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Rewrite setting rlimits which are backed by Windows job objects.
That's namely RLIMIT_AS for now, a per-process limit. Prepare for
per-user limits like RLIMIT_NPROC, but don't implement them yet.
Basically store hard and soft limits in two adjacent job objects.
Create a new per-process job object for each new process.
Two new functions, __get_os_limits() and __set_os_limits() read and
create/write the Windows job object and assign the current process to
the job.
Two new child_info methods, collect_process_rlimits() and
inherit_process_rlimits() are used in fork/exec to hand down
the process limits to the child process.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
This commit fixes the AArch64 implementation of the following three
functions: stabilize_sig_stack, setjmp and longjmp.
Changes made:
* Fixed code indentation in all three functions.
* Corrected some comments and added additional ones.
* Added missing SEH directives.
* Changed the locking algorithm in stabilize_sig_stack to Test and
Test-and-Set (TTAS).
* Stopped returning a value in x0 in stabilize_sig_stack to avoid
unnecessary clobbering. This should make it more similar to the
x86_64 version.
* Using x10 instead of x0 in setjmp and longjmp where needed as per
the previous change.
* Fixed bug in setjmp where the SP value after the prologue was used,
instead of the original one.
* Fixed bug in setjmp where the stackptr was saved at the wrong offset
into jmp_buf (should be 0).
* Now saving and restoring x0 in setjmp and x0/x1 in longjmp around the
call to stabilize_sig_stack. This should make it more similar to the
x86_64 version.
* Removed the prologue and epilogue in longjmp, as the function never
returns.
* Changed logic in longjmp to take the return value directly from the
second argument. This should make it more similar to the x86_64
version.
* Fixed bug in longjmp where the TLS stack pointer restoration used an
invalid base register.
* Using zero registers instead of an immediate 0 where possible.
Tests fixed on AArch64:
winsup.api/mmaptest02.exe
winsup.api/mmaptest03.exe
winsup.api/ltp/mmap05.exe
Signed-off-by: Igor Podgainoi <igor.podgainoi@arm.com>
|
|
Author: Radek Bartoň <radek.barton@microsoft.com>
Co-authored-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
|
|
Author: Radek Bartoň <radek.barton@microsoft.com>
Co-authored-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
|
|
Co-authored-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
|
|
This patch adds an AArch64 implementation of the sigdelayed assembly
function to Cygwin.
Tests fixed on AArch64:
winsup.api/msgtest.exe (partially)
winsup.api/sigchld.exe
winsup.api/ltp/alarm07.exe
winsup.api/ltp/kill01.exe
winsup.api/ltp/kill02.exe
winsup.api/ltp/kill03.exe
winsup.api/ltp/kill04.exe
winsup.api/ltp/pause01.exe
winsup.api/ltp/signal03.exe
Signed-off-by: Igor Podgainoi <igor.podgainoi@arm.com>
|
|
The _alloca symbol is exported only on x86_64 and is intentionally
omitted on AArch64 to prevent link-time errors.
Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
|
|
This change adds support for architecture-specific cygwin.din fragments
to allow exported symbols to vary by target CPU.
This mechanism existed prior to commit 3ba050dfcd1d
("Cygwin: fold common.din and x86_64.din into cygwin.din"), which merged
all exports into a single file when only x86 and x86_64 targets were
supported.
With the introduction of on-going AArch64 suport, architecture-specific
export control is again required. The common cygwin.din remains in the
parent directory, while per-architecture files are placed under the
respective arch sub-directories.
The build system is updated to detect and include an optional
architecture-specific cygwin.din file when generating the .def file.
Makefile.am now defines an ARCH_DIN path based on the target CPU and
passes it to scripts/gendef prior to the common cygwin.din. This ensures
architecture-specific directives, such as the LIBRARY base address or
arch-specific exports, are applied correctly while preserving the common
export definitions.
Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
The nat pipe ownership hand-over mechanism relies on the console
process list - the set of processes attached to a console, enumerable
via `GetConsoleProcessList()`. For non-cygwin process in pcon_activated
case, this list contains all processes attached to the pseudo console.
Otherwise, it contains all processes attached to the invisible console.
04f386e9af (Cygwin: console: Inherit pcon hand over from parent pty,
2024-10-31) added a last-resort fallback in `get_winpid_to_hand_over()`
that hands nat pipe ownership to any process in the console process
list, including Cygwin processes. This fallback is needed when a
Cygwin process on the pseudo console (that might be exec'ed from non-
cygwin process) must take over management of an active pseudo console
after the original owner exits.
When the pseudo console is disabled, this fallback incorrectly finds a
Cygwin process (such as the shell) and assigns it nat pipe ownership,
because both the original nat pipe owner and the shell are assosiated
with the same invisible console. Since there is no console for that
process to manage, ownership never gets released, input stays stuck on
the nat pipe.
Only the third (last-resort) call in the cascade needs guarding: the
first two calls filter for native (non-Cygwin) processes via the `nat`
parameter, and handing ownership to another native process is fine
regardless of pcon state. It is only the fallback to Cygwin processes
that is dangerous without an active pseudo console.
Guard the fallback with a `pcon_activated` check, since handing nat
pipe ownership to a Cygwin process only makes sense when there is an
active pseudo console for it to manage.
Fixes: 04f386e9af99 ("Cygwin: console: Inherit pcon hand over from parent pty")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
|
|
Previously, CSI6n was not handled correctly if the some sequences
are appended after the response for CSI6n. Especially, if the
appended sequence is a ESC sequence, which is longer than the
expected maximum length of the CSI6n response, the sequence will
not be written atomically.
Moreover, when the terminal's CSI 6n response and subsequent data
(e.g. keystrokes) arrive in the same write buffer, master::write()
processes all of it inside the pcon_start loop and returns early.
Bytes after the 'R' terminator go through per-byte line_edit() in
that loop instead of falling through to the `nat` pipe fast path
or the normal bulk `line_edit()` call. Due to this behaviour,
the chance of code conversion to the terminal code page for the
subsequent data in `to_be_read_from_nat_pipe()` case, will be lost.
Fix this by breaking out of the loop when 'R' is found and letting
the remaining data fall through to the normal write paths, which
are now reachable because `pcon_start` has been cleared.
Fixes: f20641789427 ("Cygwin: pty: Reduce unecessary input transfer.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Co-authored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
|
|
Add
- _Condition_Wait_timed_clock(),
- _Mutex_Acquire_timed_clock(),
- _Mutex_recursive_Acquire_timed_clock(), and
- _Semaphore_Wait_timed_clock().
This will ease the support of the new clock functions added in POSIX
Issue 8.
|
|
If the native (non-cygwin) app is started as background process,
the input should be kept in to_cyg mode because input data should
go to the cygwin shell that start the non-cygwin app. However,
currently it is switched to to_nat mode in a short time and reverted
to to_cyg mode just after that.
With this patch, to avoid this behaviour, switching to to_nat mode
is inhibited by checking PGID of the process, that is newly created
for a background process and differs from PGID of the tty.
Fixes: Fixes: 9fc746d17dc3 ("Cygwin: pty: Fix transferring type-ahead input between input pipes.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
|
|
In Windows 11, pseudo console uses CSI?9001h which lets the terminal
enter win32-input-mode in console. As a result, two problems happen.
1) If non-cygwin app is running in script command on the console,
Ctrl-C terminates not only the non-cygwin app, but also script
command without cleanup for the pseudo console.
2) Some remnants sequences from win32-input-mode occasionally
appears on the shell in script command on the console.
This patch fixes them by omit CSI?9001h to prevent the terminal
from entering win32-input-mode.
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Suggested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
|
|
In Windows 11, it seems that conhost.exe crashes on WriteFile() of
zero-length data to to_slave_nat. This patch skip WriteFile() if
the data length is 0.
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
|
|
In a specific rare case when a Cygwin process runs out of available
file descriptor numbers (errno set to EMFILE), the underlying Windows
HANDLE is not being closed. This is partly because currently the given
file is first opened natively before a new Cygwin file descriptor has
been assigned - the logic overlooks the fact that it is possible for
the Windows HANDLE to be valid, but not the internal fd.
Even though the object is explicitly freed from memory later using
operator delete, the fhandler_disk_file class has no destructor
defined to mitigate the leak.
This patch introduces a manual call to fh->close() if the assigned fd
value returned by the operator int &() function in the cygheap_fdnew
class is less than 0.
Test fixed on AArch64 and x86_64:
winsup.api/ltp/dup03.exe
Signed-off-by: Igor Podgainoi <Igor.Podgainoi@arm.com>
|
|
We can only handle images which can be executed on the current
architecture anyway, so this check is redundant.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Hi, I noticed that there were a few warnings about old-style function
definitions. I saw some other patches fixing the same warning, so this just
continues on from them. Now everything compiles neatly on my machine at least :)
Signed-off-by: Kim Kuparinen <kimi.h.kuparinen@gmail.com>
|
|
Under Windows on Arm (AArch64), the function hook_or_detect_cygwin will
return NULL early, which will cause the call to real_path.set_cygexec
in av::setup to accept false as a parameter instead of true.
Afterwards, in child_info_spawn::worker the call to
child_info_spawn::set would eventually pass that false result of
real_path.iscygexec() to the child_info constructor as the boolean
variable need_subproc_ready, where the flag _CI_ISCYGWIN will be
erroneously not set.
Later in child_info_spawn::worker the failed iscygwin() flag check will
cause the "parent" process handle to become non-inheritable. This patch
fixes the non-inheritability issue by introducing a new check for the
IMAGE_FILE_MACHINE_ARM64 constant in the function PEHeaderFromHModule.
Tests fixed on AArch64:
winsup.api/signal-into-win32-api.exe
winsup.api/ltp/fcntl07.exe
winsup.api/ltp/fcntl07B.exe
winsup.api/posix_spawn/chdir.exe
winsup.api/posix_spawn/fds.exe
winsup.api/posix_spawn/signals.exe
Signed-off-by: Igor Podgainoi <igor.podgainoi@arm.com>
|
|
Currently Cygwin does not support the High Entropy Virtual Addressing
feature, also known as IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA and
64-bit Address Space Layout Randomization in Windows.
Whereas on systems running on the x86_64 architecture this feature is
already disabled by default in the toolchain during the build process,
the AArch64 version of the toolchain leaves it enabled, even though it
is not mandatory to use it on Windows on Arm. Only the normal ASLR flag
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE is mandatory, which this patch
does not address.
Therefore, this patch manually introduces the addition of High Entropy
VA disabling flags into several places in various Makefile.am files.
This should prevent memory overlap bugs on AArch64.
Tests fixed on AArch64:
winsup.api/ltp/fork06.exe
winsup.api/ltp/fork07.exe
winsup.api/ltp/fork11.exe
Signed-off-by: Igor Podgainoi <igor.podgainoi@arm.com>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Aligned definition with FreeBSD to simplify porting FreeBSD headers.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
These are not strictly necessary, but POSIX headers can define
other types based on them even if stddef.h isn't included.
It also simplifies porting BSD headers.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Move the heavy machinery evaluating the fast types from stdint.h
to machine/_default_types.h. Do not try to guess from INTMAX.
In the unlikely case that __INT_FASTn_TYPE__ and __UINT_FASTn_TYPE__
are not defined, use the size-correct base types instead, just as
with the least types.
Nice side-effect: We don't need the "define fast as least" fallback
code in stdint.h anymore, given that the definitions of least
and fast types in machine/_default_types.h are now equivalent:
If fast couldn't be defined, least couldn't have been defined either.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Now that we have base definitions for these types, use them.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
These types are to be used from stdatomic.h and uchar.h.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
The winsup/ version of regex.h already had this include. Without
it, including <regex.h> by itself would not compile.
|
|
This helps debugging the DLL when it comes to Windows account info
a lot.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
NetBSD defines __dead as __attribute__((__noreturn__)). Add a matching
macro expression.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
NetBSD gencat version 1.37
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|