Commit Graph

13100 Commits

Author SHA1 Message Date
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
Mark Geisert 23b1400f83 Cygwin: Make native clipboard layout same for 32- and 64-bit
This patch unifies the layout of the clipboard descriptor cygcb_t for
32- and 64-bit Cygwin.  It allows correct copy/paste between the two
environments without corruption of user's copied data and without access
violations due to interpreting that data as a size field.

The definitions of CYGWIN_NATIVE and cygcb_t are moved to a new include
file, sys/clipboard.h.  The include file is used by fhandler_clipboard.cc
as well as getclip.c and putclip.c in the Cygwin cygutils package.

When copy/pasting between 32- and 64-bit Cygwin environments, both must
be running version 3.3.0 or later for successful operation.
2021-10-26 12:42:21 +02:00
Ken Brown 65d6818661 Cygwin: document sig2str and str2sig in version.h 2021-10-22 13:56:05 -04:00
Corinna Vinschen cb21b9cc57 Cygwin: drop outdated -O3 optimization for malloc and sync
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-22 12:47:09 +02:00
Corinna Vinschen 548f124698 Cygwin: update cygcheck OS information
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-21 18:33:35 +02:00
Takashi Yano 745b547ebd Cygwin: pipe: Use NtQuerySystemInformation() instead of EnumProcesses().
- Using EnumProcess() breaks Windows Vista compatibility. This patch
  replaces EnumProcesses() with NtQuerySystemInformation().

Addresses:
https://cygwin.com/pipermail/cygwin-developers/2021-October/012422.html
2021-10-19 11:09:47 +02:00
Takashi Yano dcd564f65c Cygwin: pty: Fix handle leak regarding attach_mutex.
- If the process having master pty opened is forked, attach_mutex
  fails to be closed when master is closed. This patch fixes the
  issue.
2021-10-10 08:57:51 -04:00
Takashi Yano 8a09deb1b7 Cygwin: pty: Fix master closing error regarding attach_mutex.
- If two or more pty masters are opened in a process, closing master
  causes error when closing attach_mutex. This patch fixes the issue.

Addresses:
https://cygwin.com/pipermail/cygwin-developers/2021-October/012418.html
2021-10-08 13:27:50 -04:00
Takashi Yano 6c1f49f83f Cygwin: pipe: Use ProcessHandleInformation if available.
- The commit b531d6b0 introduced temporary_query_hdl() which uses
  SystemHandleInformation. With this patch, ProcessHandleInformation
  rather than SystemHandleInformation is used if it is available.
  This request is faster, however, is only available since Windows 8,
  therefore, SystemHandleInformation is used for Windows Vista and 7
  as before.
2021-09-23 12:24:19 -04:00
Takashi Yano b531d6b06e Cygwin: pipe: Introduce temporary query_hdl.
- The commit f79a4611 introduced query_hdl, which is the read pipe
  handle kept in the write pipe instance in order to determine if
  the pipe is ready to write in select().  This implementation has
  a potential risk that the write side fails to detect the closure
  of the read side if more than one writer exists and one of them
  is a non-cygwin process.

  With this patch, the strategy of commit f79a4611 is used only if
  the process is running as a service.  For a normal process,
  instead of keeping query_hdl in the write pipe instance, it is
  retrieved temporarily when select() is called.  Actually, we
  want to use tenporary query_hdl for all processes, however, it
  does not work for service processes due to OpenProcess()
  failure.
2021-09-21 14:47:33 -04:00
Ken Brown 643db9ec9e Cygwin: pipes: remove unnecessary NULL checks for hdl_cnt_mtx
In view of the previous changes to open_setup, we can always assume
that hdl_cnt_mtx is non-NULL.
2021-09-18 09:25:20 -04:00
Ken Brown be08c5c40b Cygwin: make callers of open_setup check for failure
open_setup is called by dtable::init_std_file_from_handle and
fhandler_base::open_with_arch.  In both cases, failure of open_setup
is now a fatal error.

Currently this can only happen in the following situation: A Cygwin
process is started by a non-Cygwin process, one of the standard IO
handles is a pipe handle, and Cygwin is unable to create a required
mutex (read_mtx or hdl_cnt_mtx).
2021-09-18 09:10:23 -04:00
Ken Brown 6fc0aa8e5d Cygwin: fhandler_pipe::open_setup: fail on error creating mutexes 2021-09-18 08:49:06 -04:00
Ken Brown e5fcb021cc Cygwin: allow open_setup to fail
Convert fhandler_base::open_setup to a (virtual) method that returns a
bool result.  For the moment, it and its overrides always return true.
2021-09-18 08:40:11 -04:00
Ken Brown 9b0841aa78 Cygwin: statically link the tools in winsup/utils/mingw
This fixes the problem reported here:

  https://cygwin.com/pipermail/cygwin-developers/2021-September/012375.html
2021-09-17 21:38:07 -04:00
Ken Brown 98859e00d0 Cygwin: fix typos in release notes 2021-09-17 16:16:14 -04:00
Takashi Yano 9814cfd8f6 Cygwin: pipe, fifo: Move query_hdl and hdl_cnt_mtx to fhandler_pipe.
- query_hdl and hdl_cnt_mtx are moved from fhandler_pipe_fifo to
  fhandler_pipe. Then reader_closed() is changed to virtual and
  overridden in fhandler_pipe.
2021-09-16 15:53:57 -04:00
Takashi Yano 199482654b Cygwin: pipe: Fix race issue regarding handle count.
- This patch fixes the race issue in the handle counting to detect
  closure of read pipe, which is introduced by commit f79a4611.
  A mutex hdl_cnt_mtx is introduced for this issue.
2021-09-16 10:57:36 -04:00
Takashi Yano d8614e355d Cygwin: pipe: Fix error handling in fhandler_pip::create().
- Currently, error handling in fhandler_pipe::create() is broken.
  This patch fixes that.
2021-09-16 10:57:24 -04:00
Takashi Yano 350806f882 Cygwin: close_all_files: Do not duplicate stderr for write pipe.
- Currently, the stderr handle is duplicated in close_all_files().
  This interferes the handle counting for detecting closure of read
  pipe, which is introduced by commit f79a4611. This patch stops
  duplicating stderr handle if it is write pipe.
2021-09-16 10:57:14 -04:00
Ken Brown 18fab2f834 Cygwin: select: check for negative return from pipe_data_available
Make sure except_ready is set (if except_selected) on a negative
return from pipe_data_available.
2021-09-16 08:53:40 -04:00
Corinna Vinschen 34b1447040 Cygwin: pipes: don't call NtQueryInformationFile on read side of pipes
NtQueryInformationFile hangs if it's called on the read side handle of
a pipe while another thread or process is performing a blocking read.

Avoid select potentially hanging by calling NtQueryInformationFile
only on the write side of the pipe and using PeekNamedPipe otherwise.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-15 14:20:03 +02:00