Commit Graph

9452 Commits

Author SHA1 Message Date
Corinna Vinschen ba02fef995 Cygwin: Makefile.am: fix DLL build rule
A single Makefile rule creates three files in three steps, the second
and third one never showing up in dependencies.  The next step creating
the link lib only depends on the first of these files.  Even if the
second or third step in the DLL build rule fails, the next make
invocation never picks up on this and just goes ahead creating the
link lib.

Fix this by splitting the DLL build rule into three rules, with
every step on the way depending on the previous rule.  Also fix up
the names, TEST_DLL_NAME just doesn't cut it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-02 21:30:20 +01:00
Corinna Vinschen 047eaf9a6b Cygwin: drop autoloading kernel32 symbols available since Windows 7
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-28 10:36:54 +01:00
Corinna Vinschen d079ab4d37 Revert "Cygwin: fix permission problem when writing DAC info on Samba shares"
This reverts commit 0390cc8572.

There's no indication what exact situation this patch was supposed to
solve, and local testing doesn't show any such problems.  However, this
patch itself introduced a new problem, as outlined by
https://cygwin.com/pipermail/cygwin/2022-January/250629.html

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-27 15:31:25 +01:00
Corinna Vinschen f467a1da58 Cygwin: ACLs: don't set indicator for default ACEs prematurely
Commit a2bfe7cae6 introduced a change ignoring default ACEs on files
to come up with a valid POSIX ACL, reflecting the Windows ACEs actually
making sense on files.

However, if CREATOR OWNER or CREATOR GROUP ACEs - both only making sense
as default ACEs - are found in the ACL, a value indicating the presence
of default ACEs gets set, even on files.  This in turn breaks a
subsequent integrity check and get_posix_access returns EINVAL.

The code path handling default ACEs on directories sets this indicator
anyway, so don't set it just because one of the above SIDs are found.

Fixes: a2bfe7cae6 ("Cygwin: ACLs: ignore *_INHERIT flags in file ACLs")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-25 19:53:40 +01:00
Jon Turney 9c546e0fd2
Cygwin: silence most custom build rules 2022-01-19 17:13:44 +00:00
Anton Lavrentiev via Cygwin-patches 93511d575e Cygwin: resolver: cygwin_query() skip response header on internal error
- When dn_comp() failed internally there is no longer any need to
fill the response header since it's now all cleared upon entry
2022-01-19 15:26:14 +01:00
Corinna Vinschen a74707e7ac Cygwin: add resolver fixes to release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-19 08:51:03 +01:00
Anton Lavrentiev via Cygwin-patches 099d5a9a57 Cygwin: resolver: A few fixes for cygwin_query(), part 2
Make sure Windows ResultSet is free'd when dn_comp failed internally
2022-01-19 08:05:18 +01:00
Anton Lavrentiev via Cygwin-patches 54f0590a66 Cygwin: resolver: Targets in SRV DNS responses may not be compressed
RFC2782 clearly says so yet it's a common misconception to perform the
compression in the violation of the standard.  This patch fixes that
2022-01-19 08:05:18 +01:00
Anton Lavrentiev via Cygwin-patches 905f51d797 Cygwin: resolver: Fix to match response ID with request ID
In case when the native OS resolver is used (via os_query) the returned
response ID is always 0.  It should actually match the ID passed in to
res_send() in the DNS request header.  This patch fixes that
2022-01-19 08:05:18 +01:00
Anton Lavrentiev via Cygwin-patches 12bf36f72b Cygwin: resolver: A few fixes for cygwin_query()
- Make sure the answer buffer is properly cleared so there is no trailing
garbage when the response does not fit entirely in;
- Make sure an internal decomp failure gets reported correctly (w/return code -1);
- Make sure that the buffer is not overrun when filling out the header.
2022-01-19 08:05:18 +01:00
Anton Lavrentiev via Cygwin-patches fa279a583d Cygwin: resolver: Process options forward (not backwards)
Also, make sure the debug setting propagates to the parser of
the remainder of /etc/resolv.conf
2022-01-19 08:05:18 +01:00
Takashi Yano ff539cc0f9 Cygwin: fhandler_base: Fix double free caused when open() fails.
- When open fails, archetype stored in archetypes[] is not cleared.
  This causes double free when next open fail. This patch fixes the
  issue.

Addresses:
  https://cygwin.com/pipermail/cygwin/2022-January/250518.html
2022-01-18 22:17:37 +09:00
Corinna Vinschen 0cae2b802b Cygwin: add release text for last two patches
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-18 11:57:14 +01:00
Johannes Schindelin bd4fdcc059 Cygwin: path_conv: do not get confused by a directory with `.lnk` suffix
When trying to create a directory called `xyz` in the presence of a
directory `xyz.lnk`, the Cygwin runtime errors out with an `ENOENT`.

The root cause is actually a bit deeper: the `symlink_info::check()`
method tries to figure out whether the given path refers to a symbolic
link as emulated via `.lnk` files, but since it is a directory, that is
not the case, and that hypothesis is rejected.

However, the `fileattr` field is not cleared, so that a later
`.exists()` call on the instance mistakenly thinks that the symlink
actually exists. Let's clear that field.

This fixes https://github.com/msys2/msys2-runtime/issues/81

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2022-01-18 11:55:44 +01:00
Anton Lavrentiev via Cygwin-patches e195f51af7 Cygwin: resolver: Added processing of AAAA records
AAAA records returned from Windows resolver were flagged as "No
structure" in debug output because of being processed (although
correctly) in the default catch-all case.  This patch makes the AAAA
records properly recognized.
2022-01-18 11:24:48 +01:00
Anton Lavrentiev via Cygwin-patches 90947659b0 Cygwin: resolver: A little more consistency in debug messages 2022-01-18 11:24:37 +01:00
Anton Lavrentiev via Cygwin-patches 3baaf08324 Cygwin: resolver: Format spec consistency for Windows errors 2022-01-18 11:24:33 +01:00
Anton Lavrentiev via Cygwin-patches 5f40b62709 Cygwin: resolver: Debug to output both IP and port # in native b.o.
Also, change a few other debug output spots for consistency
2022-01-18 11:24:20 +01:00
Anton Lavrentiev via Cygwin-patches 1dd65a9ede Use matching format for NTSTATUS 2022-01-17 11:32:00 +01:00
Anton Lavrentiev via Cygwin-patches 746e7f1b06 Fix format specifier for wide-char string 2022-01-17 11:30:35 +01:00
Takashi Yano 909ed837cc Cygwin: pty: Fix race issue between closing and opening master.
- If the from_master is closed before cleaning up other pipes, such
  as from_slave_nat, the same pty may be allocated and pty master may
  try to open the pipe which is not closed yet, and it will fail.
  This patch fixes the issue.
2022-01-14 23:11:20 +09:00
Takashi Yano bff4594b08 Cygwin: console: Fix potential deadlock regarding acuqiring mutex.
- Acquiring input_mutex and attach_mutex in console code has potential
  risk of deadlock. This patch fixes the issue.
2022-01-14 23:11:07 +09:00
Takashi Yano 3af461092e Cygwin: pty: Stop closing and recreating attach_mutex.
- Closing attach_mutex and recreating it causes the race issue
  between pty and console codes. With this patch, attach_mutex
  is created only once in a process which opens pty, and never
  closed in order to avoid this issue.

Addresses:
  https://cygwin.com/pipermail/cygwin-developers/2021-December/012548.html
2022-01-14 23:11:01 +09:00
Takashi Yano 4f490c4cef Cygwin: pty: Fix memory leak in master_fwd_thread.
- If master_fwd_thread is terminated by cygthread::terminate_thread(),
  the opportunity to release tmp_pathbuf is missed, resulting in a
  memory leak. This patch fixes the issue.
2022-01-14 23:10:55 +09:00
Takashi Yano aa49985245 Cygwin: pty, console: Fix deadlock in GDB regarding mutex.
- GDB inferior may be suspended while the inferior grabs mutex.
  This causes deadlock in terminal I/O. With this patch, timeout
  for waiting mutex is set to 0 for the debugger process when the
  process calls CreateProcess() with DEBUG_PROCESS flag to avoid
  deadlock. This may cause the race issue in GDB, however, there
  is no other way than that.

Addresses:
 https://cygwin.com/pipermail/cygwin-developers/2021-December/012542.html
2022-01-14 23:10:47 +09:00
Brian Inglis bd179c36bf fhandler_proc.cc(format_proc_cpuinfo): add Linux 5.16 Gobble Gobble flags
0x00000007:1 Intel Advanced Matrix eXtensions:
		 EAX:22 amx_bf16 Brain Float 16 dot product
		 EAX:24 amx_tile Tile matrix multiply
		 EAX:25 amx_int8 Int 8 byte dot product
0x80000008:0 AMD EBX:27 cppc      Collaborative Processor Performance Control
2022-01-12 19:43:43 +01:00
Corinna Vinschen 935c33877d posix_spawn: fix get/set uid/gid calls for 32 bit Cygwin
32 bit Cygwin still exports function calls to support old applications.
E. g., when switching from 16 to 32 bit uid/gid values, new function
like getuid32 have been added and the old getuid function still only
provides 16 bit values.  Newly built applications using getuid are
actually calling getuid32.

However, this link magic isn't performed inside Cygwin itself, so if
newlib functions call getuid, they actually call the old getuid, not
the new getuid32.  This leads to truncated uid/gid values.

https://cygwin.com/pipermail/cygwin/2022-January/250453.html reports
how this leads to problems in posix_spawn.

Fix this temporarily. i686 support will go away soon in Cygwin and the
fix can be dropped.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-12 11:57:35 +01:00
Corinna Vinschen f574c30857 Cygwin: Makefile: add dependency to newlib's libs
We need deps to newlib's libc.a and libm.a, otherwise changes
in newlib code don't trigger a rebuild of the Cygwin DLL.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-12 11:45:54 +01:00
Corinna Vinschen a2bfe7cae6 Cygwin: ACLs: ignore *_INHERIT flags in file ACLs
get_posix_access() creates DEF_*_OBJ aclent_t entries from Windows ACEs
with INHERIT flags set, independent of the file type.  These flags only
make sense on directory objects, but certain Windows functions don't
check the file type and allow INHERIT ACE flags even on non-directories.

As a fix, make sure to ignore the INHERIT flags on non-directory ACLs
and don't propagate the matching DEF_*_OBJ aclent_t entries to callers.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-11 22:22:03 +01:00
Ken Brown 0ce992c1e4 Cygwin: fhandler_pipe::get_query_hdl_per_process: avoid a crash
NtQueryInformationProcess(ProcessHandleInformation) can return
STATUS_SUCCESS with invalid handle data for certain processes
("minimal" processes on Windows 10).  This can cause a crash when
there's an attempt to access that data.  Fix that by setting
NumberOfHandles to zero before calling NtQueryInformationProcess.

Addresses: https://cygwin.com/pipermail/cygwin-patches/2021q4/011611.html
2021-12-26 18:29:23 -05:00
Takashi Yano 80f4b7d545 Cygwin: pty: Fix input switching failure.
- This patch fixes the failure of input switching between io_handle
  and io_handle_nat. This very rarely happens, however, input is
  wrongly switched to io_handle_nat even though the non-cygwin app
  is in the background.
2021-12-15 12:25:58 +09:00
Takashi Yano 0795f704f7 Cygwin: pty: Fix conditions for input transfer again. 2021-12-14 19:20:34 +09:00
Takashi Yano 720234b78a Cygwin: pty: Fix conditions for input transfer.
- The recent commit "Cygwin: pty: Add missing input transfer when
  switch_to_pcon_in state." causes regression that rlwrap cannot
  work with cmd.exe. This patch fixes the issue.
2021-12-14 12:32:36 +09:00
Takashi Yano 8d8724ee1b Cygwin: pty: Fix Ctrl-C handling further for non-cygwin apps.
- The recent commit: "Cygwin: pty: Fix Ctrl-C handling for non-cygwin
  apps in background." causes the problem that cmd.exe is terminated
  by Ctrl-C even if it is running in pseudo console. This patch fixes
  the issue.
2021-12-13 19:43:02 +09:00
Takashi Yano 90788821b7 Cygwin: pipe: Restore blocking mode for cygwin process at startup.
- Set blocking mode properly at startup of cygwin process. This is
  needed if the cygwin process is executed from non-cygwin process.
2021-12-12 22:14:29 +09:00
Ken Brown 451bbfb9f3 Cygwin: Document that the pipe_byte option is now set by default 2021-12-12 22:14:12 +09:00
Ken Brown d9c1aeaddf Cygwin: fhandler_pipe::raw_read: minor code cleanup
Remove references to STATUS_THREAD_SIGNALED and
STATUS_THREAD_CANCELED, which can't occur any more.
2021-12-12 22:11:06 +09:00
Takashi Yano 9e4d308cd5 Cygwin: pipe: Adopt FILE_SYNCHRONOUS_IO_NONALERT flag for read pipe.
- With this patch, FILE_SYNCHRONOUS_IO_NONALERT flag is applied to
  the read pipe so that native C# programs work with cygwin pipe.
  To handle signals in reading pipe with this flag set, the read
  pipe itself is always set to nonblocking mode and simulates the
  blocking behaviour in raw_read().

- Default to byte mode rather than message mode in order to make
  C# programs work with cygwin pipe.

Addresses: https://cygwin.com/pipermail/cygwin/2021-March/247987.html
2021-12-12 22:11:05 +09:00
Takashi Yano f3d719c694 Cygwin: console: Fix console mode of non-cygwin apps in background.
- If the non-cygwin app is started in the background in console, the
  console mode is broken for the app. This patch fixes the issue.
2021-12-12 21:46:37 +09:00
Takashi Yano d593c3e17e Cygwin: pty: Fix console mode of non-cygwin apps in background.
- If the non-cygwin app is started in the background in pseudo
  console, the console mode is broken for the app. This patch fixes
  the issue.
2021-12-12 21:46:31 +09:00
Takashi Yano e91ea41ef1 Cygwin: pty: Fix Ctrl-C handling for non-cygwin apps in background.
- With pseudo console enabled, if the non-cygwin app is started in
  the background and put it into the foreground, the process cannot
  be stopped by Ctrl-C. This patch fixes the issue.
2021-12-12 21:46:24 +09:00
Takashi Yano acc44e09d1 Cygwin: pty: Add missing input transfer when switch_to_pcon_in state.
- This patch fixes the bug that input is wrongly sent to io_handle_nat
  rather than io_handle when neither read() nor select() is called
  after the cygwin app is started from non-cygwin app. This happens
  only if psuedo console is disabled.

Addresses:
  https://cygwin.com/pipermail/cygwin-patches/2021q4/011587.html
2021-12-12 21:46:05 +09:00
Takashi Yano 72175bbd28 Cygwin: clipboard: Make intent of the code clearer. 2021-12-11 23:25:16 +09:00
Takashi Yano 5aa2be8ac2 Cygwin: path: Fix path conversion of virtual drive.
- The last change in path.cc introduced a bug that causes an error
  when accessing a virtual drive which mounts UNC path such as
  "\\server\share\dir" rather than "\\server\share". This patch
  fixes the issue.
2021-12-11 22:49:52 +09:00
Takashi Yano 30089b3fbd Cygwin: path: Convert UNC path prefix back to drive letter.
- When symlink_info::check() is called with the path having drive
  letter and UNC path is mounted to the drive, the path is replaced
  with UNC path. With this patch, UNC path prefix is converted back
  to drive letter.  This fixes the issue:
  https://cygwin.com/pipermail/cygwin/2021-November/250087.html
  https://cygwin.com/pipermail/cygwin/2021-December/250103.html
2021-12-08 20:20:30 +09:00
Takashi Yano 69ed8ca20c Cygwin: clipboard: Fix a bug in read().
- Fix a bug in fhandler_dev_clipboard::read() that the second read
  fails with 'Bad address'.

Addresses:
  https://cygwin.com/pipermail/cygwin/2021-December/250141.html
2021-12-07 23:38:50 +09:00
Corinna Vinschen fb1fe93203 Cygwin: errno: handle ERROR_CASE_DIFFERING_NAMES_IN_DIR
Rather than special case status code 0xc00004b3, add status and matching
error code to ntdll.h and handle it as part of the standard error mapping.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-12-02 14:16:05 +01:00
Takashi Yano e1026837dd Cygwin: console: Fix OSC sequence handling.
- Currently, some OSC escape sequences, such as 'OSC 110 BEL', are
  not handled correctly. This patch fixes the issue.
2021-12-02 11:26:26 +09:00
Corinna Vinschen 3edea7cd55 Cygwin: get/setrlimit: move RLIMIT_AS handling into static functions
To keep getrlimit/setrlimit clean, move the RLIMIT_AS code into
local static functions __set_rlimit_as and __get_rlimit_as.

Also, make adding process to the job the last step, to be able to
close and release the job resources if anything failed.  Add matching
comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-30 12:55:14 +01:00
Corinna Vinschen 670beaed02 Cygwin: setrlimit: Add a permission check
If the incoming soft limit is less restrictive than the current
hard limit, bail out with EPERM.  Given the previous sanity check,
this implies trying to raise the hard limit.  While, theoretically,
this should be allowed for privileged processes, Windows has no
matching concept in terms of job limits

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-30 12:55:14 +01:00
Corinna Vinschen d64cd470ae Cygwin: get_rlimit_stack: add a comment
...just to see what it's used for.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-30 12:54:40 +01:00
Corinna Vinschen 3502a6ff2e Cygwin: add 3.4 release messages
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-26 17:06:00 +01:00
Corinna Vinschen 1c7384f9d1 Cygwin: get/setrlimit: implement RLIMIT_AS
Code based on the idea implemented by the oneTBB project,
see https://github.com/oneapi-src/oneTBB

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-26 17:01:28 +01:00
Ken Brown 4f47e64b11 Cygwin: fhandler_fifo::raw_read: handle STATUS_PENDING
NtReadFile can return STATUS_PENDING occasionally even in non-blocking
mode.  Check for this and wait for NtReadFile to complete.  To avoid
code repetition, do this in a static helper function nt_read.
2021-11-23 15:50:01 -05:00
Ken Brown 6d34b62cb8 Cygwin: fhandler_pipe::raw_read: fix handle leak
Slightly rearrange the code to avoid returning without closing the
event handle.
2021-11-23 10:19:49 -05:00
Takashi Yano e84b43ea93 Cygwin: Fix release note 3.3.3.
- Removes the bug fix entry that was accidentally added to the
  release notes 3.3.3, even though it had been already fixed in
  3.3.2.
2021-11-23 01:19:56 +09:00
Takashi Yano a496c9cdf8 Cygwin: sigproc: Fix potential race issue regarding exit_state.
- If sig_send() is called while another thread is processing exit(),
  race issue regarding exit_state may occur. This patch fixes the
  issue.
2021-11-22 23:26:06 +09:00
Corinna Vinschen 68faeef4be ldtoa: don't restrict outbuf size to ndigits
https://cygwin.com/pipermail/cygwin/2021-November/249930.html
reported a regression introduce by using a dynamically sized local
char array in favor of a statically sized array.

Fix this by reverting to a statically sized array, using a small
buffer on the stack for a reasonable number of requested digits, a
big mallocated buffer otherwise.  This should work for small targets
as well, given that malloc is used in printf anyway right now.

This is *still* hopefully just a temporary measure, unless somebody
actually provides a new ldtoa.

Fixes: 4d90e53359 ("ldtoa: fix dropping too many digits from output")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-22 13:57:16 +01:00
Corinna Vinschen 1fda4aebd6 Cygwin: add release message for raise fix
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-22 12:38:15 +01:00
Corinna Vinschen afb7c557d2 Cygwin: raise: align return value and error checking to Linux
raise(2) on Linux returns the same values and sets errno
independent of calling kill(2) or pthread_kill(3).  Align
code to behave the same.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-22 12:37:12 +01:00
Corinna Vinschen 24bffff63e Cygwin: raise: fix check for multithreaded process
The check for the pthread self pointer in TLS is misleading,
given the main thread has this pointer initialized as well.
Check for the global __isthreaded flag as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-22 12:37:12 +01:00
Corinna Vinschen d54d8f173d Cygwin: pthread_kill: check for invalid signal number
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-22 12:37:12 +01:00
Corinna Vinschen f03222f242 Cygwin: fhandler_netdrive: improve debug output
Add debug output for errors when calling WNet functions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-22 10:38:09 +01:00
Takashi Yano a92d69d743 Cygwin: sigproc: Do not send signal to myself if exiting.
- This patch fixes the issue that process sometimes hangs for 60
  seconds with the following scenario.
    1) Open command prompt.
    2) Run "c:\cygwin64\bin\bash -l"
    3) Compipe the following source with mingw compiler.
       /*--- Begin ---*/
       #include <stdio.h>
       int main() {return getchar();}
       /*---- End ----*/
    4) Run "tcsh -c ./a.exe"
    5) Hit Ctrl-C.
2021-11-20 02:37:52 +09:00
Takashi Yano c8b779aff4 Cygwin: console: Fix interference issue regarding master thread.
- This patch fixes the issue that ReadConsoleInputW() call in the
  master thread interferes with the input process of non-cygwin apps.
2021-11-18 14:17:15 +09:00
Takashi Yano 8c1bbf2f2c Cygwin: pipe: Suppress unnecessary set_pipe_non_blocking() call.
- Call set_pipe_non_blocking(false) only if the pipe will be really
  inherited to non-cygwin process.
2021-11-18 02:58:54 +09:00
Takashi Yano b959a54321 Cygwin: Correct the release notes 3.3.3.
- Fix incorrect description of the bug fixes part.
2021-11-18 02:46:02 +09:00
Takashi Yano 5badb8aa0a Cygwin: pipe: Handle STATUS_PENDING even for nonblocking mode.
- NtReadFile() and NtWriteFile() seems to return STATUS_PENDING
  occasionally even in nonblocking mode. This patch adds handling
  for STATUS_PENDING in nonblocking mode.

Addresses:
  https://cygwin.com/pipermail/cygwin/2021-November/249910.html
2021-11-17 08:14:23 +09:00
Corinna Vinschen 41de4b6fd7 Cygwin: fix up cached DOS file attributes after file creation
The file attributes after creating a file are not necessarily
identical to the attributes we passed as argument to NtCreateFile.
This results in subsequent operations like fchmod or facl to
set the DOS file attributes to unexpected values.

The fix is to request file attributes from the OS after file creation
and cache those.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-16 19:58:56 +01:00
Corinna Vinschen 9980177def Revert "Cygwin: set the FILE_ATTRIBUTE_ARCHIVE DOS attribute on file creation"
This reverts commit 2b28977149.

This patch fixes the symptoms, but not the actual problem.  Revert
and try again.
2021-11-16 19:58:56 +01:00
Johannes Schindelin 782aac590a Cygwin: console: Handle Unicode surrogate pairs.
When running Cygwin's Bash in the Windows Terminal (see
https://docs.microsoft.com/en-us/windows/terminal/ for details), Cygwin
is receiving keyboard input in the form of UTF-16 characters.

UTF-16 has that awkward challenge that it cannot map the full Unicode
range, and to make up for it, there are the ranges U+D800-U+DBFF and
U+DC00-U+DFFF which are illegal except when they come in a pair encoding
for Unicode characters beyond U+FFFF.

Cygwin does not handle such surrogate pairs correctly at the moment, as
can be seen e.g. when running Cygwin's Bash in the Windows Terminal and
then inserting an emoji (e.g. via Windows + <dot>, which opens an emoji
picker on recent Windows versions): Instead of showing an emoji, this
shows the infamous question mark in a black triangle, i.e. the invalid
Unicode character.

Let's special-case surrogate pairs in this scenario.

This fixes https://github.com/git-for-windows/git/issues/3281

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2021-11-16 23:20:43 +09:00
Mike Frysinger 6226bad0ea change _COMPILING_NEWLIB to _LIBC
Use the same name as glibc & gnulib to indicate "newlib itself is
being compiled".  This also harmonizes the codebase a bit in that
_LIBC was already used in places instead of _COMPILING_NEWLIB.

Building for bfin-elf, mips-elf, and x86_64-pc-cygwin produces
the same object code.
2021-11-15 19:32:23 -05:00
Corinna Vinschen 2b28977149 Cygwin: set the FILE_ATTRIBUTE_ARCHIVE DOS attribute on file creation
Do this for normal files and symlinks, not for temporary files,
device files or unix sockets.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-15 20:59:41 +01:00
Corinna Vinschen 98d10e5fd2 Cygwin: dllfixdbg: create .gnu_debuglink section in the right spot
A recent change in binutils marks the .gnu_debuglink_overlay section
as debug section.  When dllfixdbg calls objcopy -g, the section
is removed and the --add-gnu-debuglink option on the same command line
appends the section consequentially at the end of the sections.
This in turn breaks Windows Version info and, potentially, raising
the cygheap size at runtime.

Fix this by adding an explicit --keep-section=.gnu_debuglink_overlay
to the objcopy command line.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-15 13:44:57 +01:00
Corinna Vinschen 88c9008bb2 Cygwin: add 3.3.3 release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-11 11:01:23 +01:00
Corinna Vinschen 7e7d471644 Cygwin: introduce isabspath_strict macro
isabspath handles a path "X:", without trailing slash or backslash,
as absolute path.  This breaks some scenarios with relative paths
starting with "X:".  For instance, fstatat will mishandle a call
with valid dirfd and "c:" as path.

The reason is that gen_full_path_at() will check for isabspath("C:")
which returns true.  So the path will be used verbatim in fstatat,
rather than being converted to a path "<dirfd-path>/c:".

So, introduce isabspath_strict, which returns true for paths starting
with "X:" only if the next char is actually a slash or backslash.
Use it from gen_full_path_at().

This still fixes only half the problem.  The right thing would have been
to disallow using DOS paths in the first place.  Unfortunately it's much
too late for that.

Addresses: https://cygwin.com/pipermail/cygwin/2021-November/249837.html
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-11 10:48:22 +01:00
Corinna Vinschen eaf0725486 Cygwin: drop unused isabspath_u and iswabspath macros
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-11 10:48:22 +01:00
Takashi Yano 576ace1f2f Cygwin: pipe: Fix raw_write() for non-cygwin pipe with size zero.
- Currently, raw_write() fails to handle size zero pipe which may
  be created by non-cygwin apps (e.g. Windows native ninja). This
  patch fixes the issue.

Addresses:
  https://cygwin.com/pipermail/cygwin/2021-November/249844.html
2021-11-11 14:02:19 +09:00
Mike Frysinger 24491c1251 winsup: delete old _LIBC logic
This logic has never been used as we don't define _LIBC and the
reentrant.h header doesn't exist, so delete it all.
2021-11-10 20:16:15 -05:00
Takashi Yano c6f0a46d71 Cygwin: pipe: Handle WAIT_CANCELED when waiting read_mtx.
- Add missing handling for WAIT_CANCELED in cygwait() for read_mtx
  in raw_read().
2021-11-10 21:12:21 +09:00
Takashi Yano 365199090c Cygwin: pipe: Avoid false EOF while reading output of C# programs.
- If output of C# program is redirected to pipe, pipe reader falsely
  detects EOF. This happens after overhaul of pipe implementation.
  This patch fixes the issue.

Addresses:
  https://cygwin.com/pipermail/cygwin/2021-November/249777.html
2021-11-08 11:06:58 +01:00
Corinna Vinschen 55dd0676ce Cygwin: fix permission problem when writing DAC info on Samba shares
Cygwin always requests FILE_WRITE_ATTRIBUTES permissions when trying to
change DAC information.  This can lead to permission problems when
trying to chmod/chown files on Samba shares.  Drop requesting
FILE_WRITE_ATTRIBUTES on Samba shares and go with WRITE_DAC/WRITE_OWNER
only.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-04 21:52:35 +01:00
Corinna Vinschen e37bfc8ba1 Cygwin: Add a new 3.4.0 rel notes file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-04 13:14:17 +01:00
Corinna Vinschen c41fd516e0 Cygwin: add release note for rounding issue
Also rename release 3.4.0 to 3.3.2.  It doesn't make sense to
duplicate the issues fixed in 3.3.x into the 3.4.0 relnotes.
Only patches not backported into 3.3.x belong into 3.4.0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-04 13:14:17 +01:00
Takashi Yano d4e42ceb96 Cygwin: console: Prevent the exec'ed bash from exiting by Ctrl-C.
- Currently, bash occasionally exits by Ctrl-C with the following
  scenario.
    1) Start bash in the command prompt.
    2) Run 'exec bash'.
    3) Press Ctrl-C several times.
  This patch fixes the issue.
2021-11-03 14:52:03 +01:00
Corinna Vinschen eb628ca8ea Cygwin: add release note
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-11-02 15:10:58 +01:00
Takashi Yano 2221bebd71 Cygwin: console: Fix yet another bug on input when signalled.
- Currently, read() returns EINTR due to a bug if signal handler
  is SIG_DFL and the process is suspended by Ctrl-Z and restarted.
  This patch fixes the issue.
2021-11-02 11:20:50 +01:00
Takashi Yano 561767fc59 Cygwin: console: Fix a bug on input when signalled.
- This patch fixes the bug that Ctrl-C sometimes does not work as
  expected in Windows Terminal.

Addresses:
  https://cygwin.com/pipermail/cygwin/2021-November/249749.html
2021-11-02 11:20:50 +01:00
Corinna Vinschen 045ce20177 Cygwin: remove unused lsaauth authentication function
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-29 21:03:07 +02:00
Corinna Vinschen a4efb2a669 Cygwin: remove support for Vista entirely
Fix up a few comments while at it

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-29 18:19:45 +02:00
Corinna Vinschen 080eae709f Cygwin: drop support for systems not supporting the CONSOLE LOGON SID
i. e. Vista/2008.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-29 18:19:45 +02:00
Corinna Vinschen b794f2c603 Cygwin: drop support for systems not supporting RFC 4646 locales
i. e. Vista/2008.  This drops support for the sr_CS locale.

Regenerate LC_MESSAGES and LC_TIME ERA data from more recent Linux

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-29 18:19:45 +02:00
Corinna Vinschen 687c4bad28 Cygwin: drop support for systems not supporting processor groups
i. e., Vista/2008.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-29 18:19:45 +02:00
Corinna Vinschen 4bc8f1adb4 Cygwin: drop support for simple invisible console code
i. e., Vista/2008.

AllocConsole appears to allow creating a console only on the currently
visible desktop since Windows 7, which broke the simple code opening
the console on an invisible desktop in an invisible window station.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-29 18:19:45 +02:00
Corinna Vinschen e8bfe36281 Cygwin: drop support for systems not supporting QueryUnbiasedInterruptTime
i. e., Vista/2008

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-29 18:19:40 +02:00
Corinna Vinschen e36811afb4 Cygwin: drop Vista WOW64 specific child process handle bug
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-29 14:52:58 +02:00
Corinna Vinschen 7a3df8bb6f Cygwin: bump DLL major version
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-28 22:29:42 +02:00
Corinna Vinschen 3860338968 Cygwin: bump DLL minor version
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-28 13:41:19 +02:00
Corinna Vinschen 44a79a6eca Cygwin: convert malloc lock to SRWLOCK
Per https://cygwin.com/pipermail/cygwin-developers/2021-October/012429.html,
we may encounter a crash when starting multiple threads during process
startup (here: fhandler_fifo::fixup_after_{fork,exec}) which in turn
allocate memory via malloc.

The problem is concurrent usage of malloc before the malloc muto has
been initialized.

To fix this issue, convert the muto to a SRWLOCK and make sure it is
statically initalized.  Thus, malloc can be called as early as necessary
and malloc_init is only required to check for user space provided malloc.

Note that this requires to implement a __malloc_trylock macro to be
called from fork.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-26 18:47:22 +02:00