-
Notifications
You must be signed in to change notification settings - Fork 82
Rebase to v3.5.5 #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Rebase to v3.5.5 #79
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Corinna Vinschen <[email protected]>
When win32-input-mode (which is supported by Windows Termainal) is set by "\033[?9001h", cons_master_thread does not work properly and consumes larger and larger memory space. This is because sending event by WriteConsoleInput() is translated into the sequence that is used by win32-input-mode. Due to this behaviour, write-back of the INPUT_RECORDs does not work as expected. With this patch, cons_master_thread is disabled on win32-input-mode where the signal keys such as Ctrl-C, Ctrl-Z etc. never comes. Addresses: https://cygwin.com/pipermail/cygwin/2024-August/256380.html Fixes: ff4440f ("Cygwin: console: Introduce new thread which handles input signal.") Reported-by: Adamyg Mob <[email protected]> Signed-off-by: Takashi Yano <[email protected]> (cherry picked from commit 84d77e5)
After the commit 7f3c225, writing to pipe extremely slows down. This is because cygwait(select_sem, 10, cw_cancel) is called even when write operation is already completed. With this patch, the cygwait() is called only if the write operation is not completed. Addresses: https://cygwin.com/pipermail/cygwin/2024-August/256398.html Fixes: 7f3c225 ("Cygwin: pipe: handle signals explicitely in raw_write") Reported-by: Jim Reisert AD1C <[email protected]> Reviewed-by: Corinna Vinschen <[email protected]> Signed-off-by: Takashi Yano <[email protected]> (cherry picked from commit f78009c)
All three warnings produced with -Og are false positives. But given we're using -Werror unconditionally it's better to be safe than sorry. Reported-by: Kevin Ushey <[email protected]> Signed-off-by: Corinna Vinschen <[email protected]> (cherry picked from commit 2a2a648)
If a cygwin app is executed from a non-cygwin app and the cygwin app exits, the read pipe remains in the non-blocking mode because of the commit fc691d0. Due to this behaviour, the non-cygwin app cannot read the pipe correctly after that. Similarly, if a non-cygwin app is executed from a cygwin app and the non-cygwin app exits, the read pipe remains in the blocking mode. With this patch, the blocking mode of the read pipe is stored into a variable was_blocking_read_pipe on set_pipe_non_blocking() when the cygwin app starts and restored on close(). In addition, the pipe mode is set to non-blocking mode in raw_read() if the mode is blocking mode by referring the variable is_blocking_read_pipe as well. is_blocking_read_pipe is a member of fhandler_pipe class and is set by set_pipe_non_blocking(), so if other process sets the pipe mode to blocking mode, the current process cannot know the pipe is blocking mode. Therefore, is_blocking_read_pipe is also set on the signal __SIGNONCYGCHLD, which is sent to the process group when non-cygwin app is started. Addresses: git-for-windows/git#5115 Fixes: fc691d0 ("Cygwin: pipe: Make sure to set read pipe non-blocking for cygwin apps."); Reported-by: isaacag, Johannes Schindelin <[email protected]> Reviewed-by: Corinna Vinschen <[email protected]>, Ken Brown <[email protected]> Signed-off-by: Takashi Yano <[email protected]>
If the parent process has already used pread() or pwrite(), these functions fail with EBADF if used on the inherited fd. Ensure that fix_after_fork() is called to invalidate the prw_handle. This issue has been detected by 'stress-ng --pseek 1'. Fixes: c36cd56 ("* fhandler.cc (fhandler_base::open): Drop local create_options variable.") Signed-off-by: Christian Franke <[email protected]>
timer_delete() always returned failure. This issue has been detected by 'stress-ng --hrtimers 1'. Fixes: 229ea3f ("Cygwin: posix timers: reimplement using OS timer") Signed-off-by: Christian Franke <[email protected]>
The decomposition needs to be into 12+24 bits of precision for extra- precision multiplication, but was into 13+24 bits. On i386 with -O1 the bug was hidden by accidental extra precision, but on amd64, in 2^32 trials the bug caused about 200000 errors of more than 1 ulp, with a maximum error of about 80 ulps. Now the maximum error in 2^32 trials on amd64 is 0.8573 ulps. It is still 0.8316 ulps on i386 with -O1. The nearby decomposition of 1/ln2 and the decomposition of 2/(3ln2) in the double precision version seem to be sub-optimal but not broken. Reference: freebsd/freebsd-src@b4437c3 Original Author: Bruce Evans
(1) The bit for the 1.0 part of bp[k] was right shifted by 4. This
seems to have been caused by a typo in converting e_pow.c to
e_powf.c.
(2) The lower 12 bits of ax+bp[k] were not discarded, so t_h was
actually plain ax+bp[k]. This seems to have been caused by a logic
error in the conversion.
These bugs gave wrong results like:
powf(-1.1, 101.0) = -15158.703 (should be -15158.707)
hex values: BF8CCCCD 42CA0000 C66CDAD0 C66CDAD4
Fixing (1) gives a result wrong in the opposite direction
(hex C66CDAD8), and fixing (2) gives the correct result.
ucbtest has been reporting this particular wrong result on i386 systems
with unpatched libraries for 9 years. I finally figured out the extent
of the bugs. On i386's they are normally hidden by extra precision.
We use the trick of representing floats as a sum of 2 floats (one much
smaller) to get extra precision in intermediate calculations without
explicitly using more than float precision. This trick is just a
pessimization when extra precision is available naturally (as it always
is when dealing with IEEE single precision, so the float precision part
of the library is mostly misimplemented). (1) and (2) break the trick
in different ways, except on i386's it turns out that the intermediate
calculations are done in enough precision to mask both the bugs and
the limited precision of the float variables (as far as ucbtest can
check).
ucbtest detects the bugs because it forces float precision, but this
is not a normal mode of operation so the bug normally has little effect
on i386's.
On systems that do float arithmetic in float precision, e.g., amd64's,
there is no accidental extra precision and the bugs just give wrong
results.
Reference: freebsd/freebsd-src@12be4e0
Original Author: Bruce Evans
Fixed another precision bug in powf(). This one is in the computation [t=p_l+p_h High]. We multiply t by lg2_h, and want the result to be exact. For the bogus float case of the high-low decomposition trick, we normally discard the lowest 12 bits of the fraction for the high part, keeping 12 bits of precision. That was used for t here, but it doesnt't work because for some reason we only discard the lowest 9 bits in the fraction for lg2_h. Discard another 3 bits of the fraction for t to compensate. This bug gave wrong results like: powf(0.9999999, -2.9999995) = 1.0000002 (should be 1.0000001) hex values: 3F7FFFFF C03FFFFE 3F800002 3F800001 As explained in the log for the previous commit, the bug is normally masked by doing float calculations in extra precision on i386's, but is easily detected by ucbtest on systems that don't have accidental extra precision. Reference: freebsd/freebsd-src@5f20e5c Original Author: Bruce Evans
Previously, adding a new lock by lockf() over multiple existing locks failed. This is due to a bug that lf_setlock() tries to create a lock that has already been created. This patch fixes the issue. Addresses: https://cygwin.com/pipermail/cygwin/2024-October/256528.html Fixes: a998dd7 ("* flock.cc: Implement all advisory file locking here.") Reported-by: Christian Franke <[email protected]> Reviewed-by: Corinna Vinschen <[email protected]> Signed-off-by: Takashi Yano <[email protected]>
Previously, lockf() printed a warning message when the number of locks per file exceeds the limit (MAX_LOCKF_CNT). This patch makes lockf() return ENOLCK in that case rather than printing the warning message. Addresses: https://cygwin.com/pipermail/cygwin/2024-October/256528.html Fixes: 31390e4 ("(inode_t::get_all_locks_list): Use pre-allocated buffer in i_all_lf instead of allocating every lock. Return pointer to start of linked list of locks.") Reported-by: Christian Franke <[email protected]> Reviewed-by: Corinna Vinschen <[email protected]> Signed-off-by: Takashi Yano <[email protected]>
There was a long-standing issue that pseudo console ownership could not hand over from the process whose ctty is /dev/cons* rather than /dev/pty*. This problem happens when a cygwin app starts non-cygwin app in a pty, then the non-cygwin app starts multiple cygwin apps, and the non-cygwin app ends before the second cygwin apps end. In this case, the stub process of the non-cygwin app hands over the ownership of pcon to one of the second cygwin apps, however, this app does not hand over the ownership of pcon to another second cygwin app. This is due to the fact that the hand-over feature is implemented only in fhandler_pty_slave but not in fhandler_console. With this patch, the second cygwin apps check if their console device is inside a pseudo console, and if so, it tries to hand over the ownership of the pseudo console to anther process that is attached to the same pseudo console. Addresses: https://cygwin.com/pipermail/cygwin/2024-February/255388.html Fixes: 253352e ("Cygwin: pty: Allow multiple apps to enable pseudo console simultaneously.") Reported-by: lmari Lauhakangas <[email protected]>, Hossein Nourikhah <[email protected]> Signed-off-by: Takashi Yano <[email protected]>
The expression computing the next-less-power of 2 for the next write when the pipe buffer is getting filled up allows negative shift values. This works on Intel CPUs because the shift expression only evaluates the 5 LSBs, but it's undefined behaviour per the C standard. Use the correct expression to get a positive shift value. Fixes: 170e6ba ("Cygwin: pipe: improve writing when pipe buffer is almost full") Reported-by: Takashi Yano <[email protected]> Signed-off-by: Corinna Vinschen <[email protected]>
Previously, sigfe had a long-standing problem that the signal handler destroys fpu states. This is caused by fninit instruction in sigdelayed. With this patch, instead of fnstcw/fldcw and fninit, fnstenv/fldenv are used to maintain fpu states. Addresses: https://cygwin.com/pipermail/cygwin/2024-October/256503.html Fixes: ed89fbc ("* gendef (sigdelayed (x86_64)): Save and restore FPU control word.") Reported-by: Christian Franke <[email protected]> Reviewed-by: Signed-off-by: Takashi Yano <[email protected]>
Currently, open() tries to attach to the console which is owned by the console owner process. However, when the owner process calls exec(), AttachConsole() to dwProcessId may sometimes fail due to unlucky timing. With this patch, open() tries to attach also to exec_dwProcessId if attaching to dwProcessId fails. That is, open() tries to attach to both the stub process and target process to prevent the above situation. Fixes: 3721a75 ("Cygwin: console: Make the console accessible from other terminals.") Signed-off-by: Takashi Yano <[email protected]>
Previous fix (commit df0953a) fixes only a part of the problem. Since exec() overrides the cygwin pid of the caller process, it makes console owner handling complex. This patch makes console use Windows pid as the owner pid (con.owner) instead of cygwin pid to make the handling simpler. Fixes: df0953a ("Cygwin: console: Fix open() failure when the console owner calls exec().") Signed-off-by: Takashi Yano <[email protected]> (cherry picked from commit 90ddab9)
…ssId The commit 90ddab9 uses myself->dwProcessId to get windows pid. However, it will be overridden in stub process if exec() is called. With this patch, GetCurrentProcessId() instead of myself->dwProcessId. Fixes: 90ddab9 ("Cygwin: console: Re-fix open() failure on exec() by console owner") Signed-off-by: Takashi Yano <[email protected]> (cherry picked from commit 8ee8b0c)
Previously, the condition to clean up input/output mode was based on wrong premise. This patch fixes that. Fixes: 8ee8b0c ("Cygwin: console: Use GetCurrentProcessId() instead of myself->dwProcessId") Signed-off-by: Takashi Yano <[email protected]> (cherry picked from commit 30d2669)
…ntax errors
This commit revises `pthread_cleanup_push` and `pthread_cleanup_pop`
macros to use a `do { ... } while(0)` wrapper, preventing syntax errors
when used in certain contexts. The original code could fail when they
are wrapped within a `do { ... } while(0)`, causing unintended behavior
or compilation issues.
Example of error:
#include <pthread.h>
#define pthread_cleanup_push_wrapper(_fn, _arg) do { \
pthread_cleanup_push(_fn, _arg); \
} while (0)
#define pthread_cleanup_pop_wrapper(_execute) do { \
pthread_cleanup_pop(_execute); \
} while (0)
void cleanup_fn (void *arg) {}
void *thread_func (void *arg)
{
pthread_cleanup_push_wrapper(cleanup_fn, NULL);
pthread_cleanup_pop_wrapper(1);
return NULL;
}
int main (int argc, char **argv) {
pthread_t thread_id;
pthread_create(&thread_id, NULL, thread_func, NULL);
}
This would fail due to unmatched braces in the macro expansion. The new
structure ensures the macro expands correctly in all cases.
Fixes: 007276b ("* cygwin.din: Add _pthread_cleanup_push and _pthread_cleanup_pop.")
Signed-off-by: Shaobo Song <[email protected]>
Change the first parameter of pthread_sigqueue() to be a thread id rather than a thread pointer. The change is to match the Linux implementation of this function. The user-visible function prototype is changed in include/pthread.h. The pthread_sigqueue() function is modified to work with a passed-in thread id rather than an indirect thread pointer as before. (It used to be "pthread_t *thread", i.e., class pthread **.) The release note for Cygwin 3.5.5 is updated. Reported-by: Christian Franke <[email protected]> Addresses: https://cygwin.com/pipermail/cygwin/2024-September/256439.html Signed-off-by: Mark Geisert <[email protected]> Fixes: 50350ca ("* cygwin.din (pthread_sigqueue): Export.") (cherry picked from commit 1e8c92e)
The pointer pfni gets allocated the buffer at the begin, and is used in the NtQueryDirectoryFile call before the loops. In the loop the pointer pfni is also used as iterator. Therefore it holds no longer the initial buffer at the call to NtQueryDirectoryFile in the while conditition at the bottom. Fixes: 28fa2a7 ("* syscalls.cc (check_dir_not_empty): Check surplus directory entries") Co-authored-by: Corinna Vinschen <[email protected]> Signed-off-by: Bernhard Übelacker <[email protected]> (cherry picked from commit dbb8069)
The commit ae181b0 has a bug that the pointer is referred bofore NULL check in the function lf_clearlock(). This patch fixes that. Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256750.html Fixes: ae181b0 ("Cygwin: lockf: Make lockf() return ENOLCK when too many locks") Reported-by: Sebastian Feld <[email protected]> Reviewed-by: Corinna Vinschen <[email protected]> Signed-off-by: Takashi Yano <[email protected]> (cherry picked from commit e7ef920)
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: 2e560a0 ("* flock.cc (LOCK_OBJ_NAME_LEN): Change to accommodate extra lf_ver field.") Reported-by: Sebastian Feld <[email protected]> Reviewed-by: Corinna Vinschen <[email protected]> Signed-off-by: Takashi Yano <[email protected]> (cherry picked from commit 8dee07a)
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: d4689b9 ("Cygwin: Set threadnames with SetThreadDescription()") Signed-off-by: Corinna Vinschen <[email protected]> (cherry picked from commit 21a2c9d)
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: 24ff42d ("Cygwin: Implement sigtimedwait") Reported-by: Christian Franke <[email protected]> Reviewed-by: Corinna Vinschen <[email protected]> Signed-off-by: Takashi Yano <[email protected]> (cherry picked from commit 26144e4)
Fixes: 6b2a2aa ("Add missing files.") Signed-off-by: Christian Franke <[email protected]>
Behave like sched_setparam() if the requested policy is identical to the fixed value (SCHED_FIFO) returned by sched_getscheduler(). Fixes: 9a08b2c ("* sched.cc: New file. Implement sched*.") Signed-off-by: Christian Franke <[email protected]> (cherry picked from commit 522f3e9)
Currently, the buffer of 128KB is passed to GetConsoleProcessList(). This causes page fault in the select() loop for console due to: microsoft/terminal#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: 7277014 ("Cygwin: pty: Prevent pty from changing code page of parent console.") Reported-by: Steven Buehler <[email protected]> Signed-off-by: Takashi Yano <[email protected]> (cherry picked from commit 1a49c17)
This addresses an extremely difficult to debug deadlock when running under emulation on ARM64. A relatively easy way to trigger this bug is to call `fork()`, then within the child process immediately call another `fork()` and then `exit()` the intermediate process. It would seem that there is a "code emulation" lock on the wait thread at this stage, and if the thread is terminated too early, that lock still exists albeit without a thread, and nothing moves forward. It seems that a `SuspendThread()` combined with a `GetThreadContext()` (to force the thread to _actually_ be suspended, for more details see https://devblogs.microsoft.com/oldnewthing/20150205-00/?p=44743) makes sure the thread is "booted" from emulation before it is suspended. Hopefully this means it won't be holding any locks or otherwise leave emulation in a bad state when the thread is terminated. Also, attempt to use `CancelSynchonousIo()` (as seen in `flock.cc`) to avoid the need for `TerminateThread()` altogether. This doesn't always work, however, so was not a complete fix for the deadlock issue. Addresses: https://cygwin.com/pipermail/cygwin-developers/2024-May/012694.html Signed-off-by: Jeremy Drake <[email protected]>
It appears this is causing hangs on native x86_64 in similar scenarios as the hangs on ARM64, because `CancelSynchronousIo` is returning `TRUE` but not canceling the `ReadFile` call as expected. Addresses: msys2/MSYS2-packages#4340 (comment) Fixes: b091b47 ("cygthread: suspend thread before terminating.") Signed-off-by: Jeremy Drake <[email protected]>
This was already used in the FAST_CWD check, and could be used in a couple other places. I found the "emulated"/process value returned from the function largely useless, so I did not cache it. It is useless because, as the docs say, it is set to IMAGE_FILE_MACHINE_UNKNOWN (0) if the process is not running under WOW64, but Microsoft also doesn't consider x64-on-ARM64 to be WOW64, so it is set to 0 regardless if the process is ARM64 or x64. You can tell the difference via GetProcessInformation(ProcessMachineTypeInfo), but for the current process even that's overkill: what we really want to know is the IMAGE_FILE_MACHINE_* constant for the Cygwin dll itself, which is conveniently located in memory already, so cache that in wincap also for easy comparisons. Signed-off-by: Jeremy Drake <[email protected]> (cherry picked from commit 46f7bcc)
If the Cygwin dll's architecture is different from the host system's architecture, append an additional tag that indicates the host system architecture (the Cygwin dll's architecture is already indicated in machine). Signed-off-by: Jeremy Drake <[email protected]> (cherry picked from commit 7923059)
This commit starts the rebase of 886813e to d1ca2c90a1
Seeing as Git for Windows tries to stay close to the upstream MSYS2 project, it makes sense to integrate their patches verbatim. Signed-off-by: Johannes Schindelin <[email protected]>
Even when the character set is specified as ASCII, we should handle data outside the 7-bit range gracefully by simply copying it, even if it is technically no longer ASCII. This fixes several of Git for Windows' tests, e.g. t7400. Signed-off-by: Johannes Schindelin <[email protected]>
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v2...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]>
It came in real handy while debugging an issue that strace 'fixed'. Signed-off-by: Johannes Schindelin <[email protected]>
See https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot#enabling-dependabot-version-updates-for-actions for details. Signed-off-by: Johannes Schindelin <[email protected]>
When a non ascii char is at the beginning of a path the current conversion destroys the path. This fix will prevent this with an extra check for non-ascii UTF-8 characters. Helped-by: Johannes Schindelin <[email protected]> Signed-off-by: 마누엘 <[email protected]>
This is a forked repository... Signed-off-by: Johannes Schindelin <[email protected]>
* dcrt0.cc (dll_crt0_1), dtable.cc (handle_to_fn), environ.cc (environ_init, getwinenveq, build_env), external.cc (fillout_pinfo), fhandler_disk_file.cc (__DIR_mounts::eval_ino, fhandler_disk_file::readdir_helper), fhandler_netdrive.cc (fhandler_netdrive::readdir), fhandler_process.cc (format_process_winexename, format_process_maps, format_process_stat, format_process_status), fhandler_procsys.cc (fill_filebuf, fhandler_procsys::readdir), mount.cc (fs_info::update, mount_info::create_root_entry, mount_info::conv_to_posix_path, mount_info::from_fstab_line), nlsfuncs.cc (internal_setlocale), path.cc (path_conv::check, sysmlink_info::check_shortcut, symlink_info::check_sysfile, symlink_info::check_reparse_point, symlink_info::check_nfs_symlink, cygwin_conv_path, cygwin_conv_path_list, cwdstuff::get_error_desc, cwdstuff::get), strfuncs.cc (sys_wcstombs_no_path, sys_wcstombs_alloc_no_path), uinfo.cc (ontherange, fetch_from_path, cygheap_pwdgrp::get_home, cygheap_pwdgrp::get_shell, cygheap_pwdgrp::get_gecos), wchar.h (sys_wcstombs_no_path, sys_wcstombs_alloc_no_path): Convert call sites of the sys_wcstombs*() family to specify explicitly when the parameter refers to a path or file name, to avoid future misconversions. Detailed explanation: The sys_wcstombs() function contains special handling for paths/file names, to work around file name restriction on Windows that are unexpected in the POSIX context of Cygwin. We actually do not want that special handling for WCS strings that do *not* refer to paths or file names. Neither do we want to convert those special file names unless they come from inside Cygwin: if the source of the string value is the Windows API, we *know* it cannot be such a special file name because Windows itself would not be able to handle it in the way Cygwin does. So let's switch the previous sys_wcstombs()/sys_wcstombs_no_path() (and the *_alloc* variant) around to sys_wcstombs_path()/sys_wcstombs(). We do this for several reasons: - whenever a call site wants to convert a WCS representation of a path or file name to an MBS one, it should be made very clear that we *want* the special file name conversion to happen. - it is shorter to read and write. - future calls to sys_wcstombs() will not incur unwanted conversion by accident (it is easy for unsuspecting programmers to assume that the function name "sys_wcstombs()" refers to a regular text conversion that has nothing to do with paths or filenames). By keeping the name sys_wcstombs() (and not switching to sys_wcstombs_path()), the following call sites are implicitly changed to *exclude* the special path/file name conversion: cygheap.h (get_drive): Cannot contain special characters external.cc (cygwin_internal): Refers to user/domain names, not paths fhandler_clipboard.cc (fhandler_dev_clipboard::read): Is not a path or file name but characters from the Windows clipboard fhandler_console.cc: (dev_console::con_to_str): Is not a path or file name but characters from the console fhandler_registry.cc (encode_regname): Is a registry key, not a path or filename fhandler_registry.cc (multi_wcstombs): All call sites pass registry values, not paths or filenames fhandler_registry.cc (fstat): Is a registry value, not a path or filename fhandler_registry.cc (fill_filebuf): Is a registry value, not a path or filename net.cc (get_ipv4fromreg): Is a registry value, not a path or filename net.cc (get_friendlyname): Is a device name, not a path or filename netdb.cc (open_system_file): Is from outside Cygwin smallprint.cc (__small_vsprintf): Is a free text, not a path or filename strfuncs.cc (strlwr): Should preserve the characters from the private page if there are any strfuncs.cc (strupr): Should preserve the characters from the private page if there are any uinfo.cc (cygheap_user::init): Refers to a user name, not a path or filename uinfo.cc (pwdgrp::fetch_account_from_windows): Refers to value from outside Cygwin By keeping the function name sys_wcstombs_alloc() (and not changing it to sys_wcstombs_alloc_path()), the following call sites are implicitly changed to *exclude* the special path/file name conversion: ldap.cc (cyg_ldap::remap_uid): Refers to a user name, not a path or filename ldap.cc (cyg_ldap::remap_gid): Refers to a group name, not a path or filename pinfo.cc (_pinfo::cmdline): Refers to a command line from Windows, outside Cygwin uinfo.cc (cygheap_user::env_logsrv): Is a server name, not a path or filename uinfo.cc (cygheap_user::env_domain): Refers to the user/domain name, not a path or filename uinfo.cc (cygheap_user::env_userprofile): Refers to Windows' idea of a path, outside Cygwin uinfo.cc (cygheap_user::env_systemroot): Refers to Windows' idea of a path, outside Cygwin uinfo.cc (fetch_from_description): Refers to values from outside of Cygwin uinfo.cc (cygheap_pwdgrp::get_gecos): Refers to user/domain name and email address, not path nor filename Signed-off-by: Johannes Schindelin <[email protected]>
Windows native symlinks must match the type of their target (file or directory), otherwise native Windows tools will fail. Creating symlinks in 'nativestrict' mode currently requires the target to exist in order to check its type. However, the target of a symlink can change at any time after the symlink has been created. Thus users of native symlinks must be prepared to deal with type mismatches anyway. Checking the target type at symlink creation time is not a good reason to violate the symlink() API specification. In 'nativestrict' mode, always create native symlinks. Choose the symlink type according to the target if it exists. Otherwise check the target path for a trailing '/' as hint to create a directory symlink. This allows callers to explicitly specify the expected target type, e.g.: $ ln -s test/ link-to-test $ mkdir test Signed-off-by: Karsten Blees <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims to use the "ASCII" charset. But the `MB_CUR_MAX` value (which is not actually a constant, but dependent on the current locale) was still 1, which broke the initial `globify()` call while parsing the the command-line in `build_argv()` for non-ASCII arguments. This fixes git-for-windows/git#2189 Signed-off-by: Johannes Schindelin <[email protected]>
This might break things, but it turns out several Windows libraries like to be loaded at 0x180000000. This causes a problem, because `msys-2.0.dll` loads at `0x180040000` and expects `0x180000000-0x180040000` to be available. A problem arises when Antiviruses (or other DLL hooking mechanisms) load a DLL whose preferred load address is `0x180000000` and fits in size before `0x180010000`: 1. `msys-2.0.dll` loads and fills `0x180010000-0x180040000` assuming no shared console structure is going to be needed. 2. Another DLL loads and fills `0x180000000-0x18000xxxx` 3. `msys-2.0.dll` tries to load `0x180000000-0x180010000` but it's not available. It falls back to another address, but down the line something else fails. This bug triggers when using subshells (e.g.: `git clone --recursive`). The MSYS2 runtime should be able to work around the address conflict, but the code is failing in some way or other... Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Mikael Larsson <[email protected]>
Assorted fixes for Git for windows
Allow native symlinks to non-existing targets in 'nativestrict' mode
This topic branch fixes the problem where a UTF-16 command-line was converted to UTF-8 in an incorrect way (because Cygwin treated it as if it was a file name and applied some magic that is intended to allow for otherwise invalid file names on Windows). Signed-off-by: Johannes Schindelin <[email protected]>
Workaround certain anti-malware programs Signed-off-by: Johannes Schindelin <[email protected]>
Commit a5bcfe6 removed an optimization that fetches the default group from the current user token, as it is sometimes not accurate such as when groups like the builtin Administrators group is the primary group. However, removing this optimization causes extremely poor performance when connected to some Active Directory environments. Restored this optimization as the default behaviour, and added a `group: db-accurate` option to `nsswitch.conf` that can be used to disable the optimization in cases where accurate group information is required. This fixes git-for-windows/git#4459 Signed-off-by: Richard Glidden <[email protected]>
msys2-runtime: restore fast path for current user primary group
It was reported in git-for-windows/git#5199 that as of v3.5.4, cloning or fetching via SSH is hanging indefinitely. Bisecting the problem points to 555afcb (Cygwin: select: set pipe writable only if PIPE_BUF bytes left, 2024-08-18). That commit's intention seems to look at the write buffer, and only report the pipe as writable if there are more than one page (4kB) available. However, the number that is looked up is the number of bytes that are already in the buffer, ready to be read, and further analysis shows that in the scenario described in the report, the number of available bytes is substantially below `PIPE_BUF`, but as long as they are not handled, there is apparently a dead-lock. Since the old logic worked, and the new logic causes a dead-lock, let's essentially revert 555afcb (Cygwin: select: set pipe writable only if PIPE_BUF bytes left, 2024-08-18). Note: This is not a straight revert, as the code in question has been modified subsequently, and trying to revert the original commit would cause merge conflicts. Therefore, the diff looks very different from the reverse diff of the commit whose logic is reverted. Signed-off-by: Johannes Schindelin <[email protected]>
Fix SSH hangs
Member
Author
|
/open pr The workflow run was started |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Range-diff relative to main
1: 51380ec = 1: bdad035 Add MSYS2 triplet
2: a116f41 = 2: 900232b Fix msys library name in import libraries
3: f858c02 ! 3: 585fadf Rename dll from cygwin to msys
@@ winsup/cygwin/syscalls.cc: try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK ac { - /* Create unique filename. Start with a dot, followed by "cyg" + /* Create unique filename. Start with a dot, followed by "msys" - transposed into the Unicode low surrogate area (U+dc00) on file - systems supporting Unicode (except Samba), followed by the inode - number in hex, followed by a path hash in hex. The combination + transposed to the Unicode private use area in the U+f700 area + on file systems supporting Unicode (except Samba), followed by + the inode number in hex, followed by a path hash in hex. The @@ winsup/cygwin/syscalls.cc: try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access, ULONG flags) RtlAppendUnicodeToString (&recycler, (pc.fs_flags () & FILE_UNICODE_ON_DISK && !pc.fs_is_samba ()) -- ? L".\xdc63\xdc79\xdc67" : L".cyg"); -+ ? L".\xdc6d\xdc73\xdc79\xdc73" : L".msys"); +- ? L".\xf763\xf779\xf767" : L".cyg"); ++ ? L".\xf76d\xf773\xf779\xf773" : L".msys"); pfii = (PFILE_INTERNAL_INFORMATION) infobuf; status = NtQueryInformationFile (fh, &io, pfii, sizeof *pfii, FileInternalInformation);4: b084abe = 4: d076660 Add functionality for converting UNIX paths in arguments and environment variables to Windows form for native Win32 applications.
5: f160385 = 5: 35a477b Add functionality for changing OS name via MSYSTEM environment variables.
6: 6393488 = 6: 41ed62e - Move root to /usr. - Change sorting mount points. - By default mount without ACLs. - Can read /etc/fstab with short mount point format.
7: 06ea20e = 7: 8096583 Instead of creating Cygwin symlinks, use deep copy by default
8: 222fd37 = 8: 0ba54e8 Automatically rewrite TERM=msys to TERM=cygwin
9: 41e8ada = 9: e28b742 Do not convert environment for strace
10: 766e55c = 10: 4a24304 strace.cc: Don't set MSYS=noglob
11: 4f01c3f = 11: b3a4a5b Add debugging for strace make_command_line
12: d43f1ee = 12: f8c0980 strace --quiet: be really quiet
13: 0053f7b = 13: c4d9d83 path_conv: special-case root directory to have trailing slash
14: 1e8a891 = 14: 1c5a6e8 When converting to a Unix path, avoid double trailing slashes
15: 673065d = 15: 8b5e9b5 msys2_path_conv: pass PC_NOFULL to path_conv
16: e1db148 = 16: b09fb7f path-conversion: Introduce ability to switch off conversion.
17: f6e516d = 17: b239180 dcrt0.cc: Untangle allow_glob from winshell
18: 1059fbb = 18: 1e94f3e dcrt0.cc (globify): Don't quote literal strings differently when dos_spec
19: f8da08f = 19: e6c5e3e Add debugging for build_argv
20: 03d6fe1 = 20: d44fc10 environ.cc: New facility/environment variable MSYS2_ENV_CONV_EXCL
21: 90d66ee = 21: 98c1641 Fix native symbolic link spawn passing wrong arg0
22: 7b84fed = 22: d12ab6d Introduce the
enable_pconvalue forMSYS23: 6f87e23 = 23: 865ad5d popen: call /usr/bin/sh instead of /bin/sh
24: df7a56e = 24: 5f36fdb Disable the 'cygwin' GitHub workflow
25: cf56ccd ! 25: 862887f CI: add a GHA for doing a basic build test
26: 083c245 = 26: 764bd7f CI: fix the build with gcc 13
27: 91f46df = 27: bea6a07 Set up a GitHub Action to keep in sync with Cygwin
28: 4dd6aad = 28: 080e2b0 Expose full command-lines to other Win32 processes by default
29: 6ef58ed = 29: 9f45f58 Add a helper to obtain a function's address in kernel32.dll
30: 38a8880 = 30: f6f7e2c Emulate GenerateConsoleCtrlEvent() upon Ctrl+C
31: b9d1fad = 31: 86cd50d kill: kill Win32 processes more gently
32: 715f6ce = 32: 4b228ef Cygwin: make option for native inner link handling.
33: abeeb31 = 33: 6e0c3b5 docs: skip building texinfo and PDF files
34: fbe8ae3 = 34: ecf50e6 install-libs: depend on the "toollibs"
35: 38abc7c = 35: 8cb4ff2 POSIX-ify the SHELL variable
36: 9c758e8 = 36: 1f6020c Handle ORIGINAL_PATH just like PATH
37: 312f766 = 37: 79e3880 uname: allow setting the system name to CYGWIN
38: e19af20 = 38: ef59c45 Pass environment variables with empty values
39: 4deb751 = 39: c347d6c Optionally disallow empty environment values again
40: a1f282d = 40: 210e5f3 build_env(): respect the
MSYSenvironment variable41: d1b382b = 41: bef1e6b Revert "Cygwin: Enable dynamicbase on the Cygwin DLL by default"
42: 997f6f3 = 42: 8103a09 CI: set -Wno-error=maybe-uninitialized
43: e347515 = 43: 6e10b1b Avoid sharing cygheaps across Cygwin versions
44: dd9d970 = 44: f61f7fb uname: report msys2-runtime commit hash, too
45: 2bfb773 (upstream: 37ab3e0) < -: ---------- Cygwin: pipe: Fix a regression that raw_write() slows down
46: c325a46 < -: ---------- fixup!!! CI: add a GHA for doing a basic build test
62: 6183b83 = 45: debafbf Cygwin: find_fast_cwd: don't run assembler checking code on ARM64
63: bf47028 ! 46: 2c55ca5 cygthread: suspend thread before terminating.
@@ Commit message the need for `TerminateThread()` altogether. This doesn't always work, however, so was not a complete fix for the deadlock issue. - Cherry picked from commit e09c64ef65 (cygthread: suspend thread before - terminating., 2024-11-11) from msys2/msys2-runtime. - Addresses: https://cygwin.com/pipermail/cygwin-developers/2024-May/012694.html Signed-off-by: Jeremy Drake <[email protected]> - Signed-off-by: Johannes Schindelin <[email protected]> ## winsup/cygwin/cygthread.cc ## @@ winsup/cygwin/cygthread.cc: cygthread::terminate_thread () @@ winsup/cygwin/cygthread.cc: cygthread::terminate_thread () WaitForSingleObject (h, INFINITE); CloseHandle (h); + ## winsup/cygwin/pinfo.cc ## +@@ winsup/cygwin/pinfo.cc: proc_waiter (void *arg) + + for (;;) + { +- DWORD nb; ++ DWORD nb, err; + char buf = '\0'; + + if (!ReadFile (vchild.rd_proc_pipe, &buf, 1, &nb, NULL) +- && GetLastError () != ERROR_BROKEN_PIPE) ++ && (err = GetLastError ()) != ERROR_BROKEN_PIPE) + { +- system_printf ("error on read of child wait pipe %p, %E", vchild.rd_proc_pipe); ++ /* ERROR_OPERATION_ABORTED is expected due to the possibility that ++ CancelSynchronousIo interruped the ReadFile call, so don't output ++ that error */ ++ if (err != ERROR_OPERATION_ABORTED) ++ system_printf ("error on read of child wait pipe %p, %E", vchild.rd_proc_pipe); + break; + } + + ## winsup/cygwin/sigproc.cc ## @@ winsup/cygwin/sigproc.cc: proc_terminate () + to 1 iff it is a Cygwin process. */ if (!have_execed || !have_execed_cygwin) chld_procs[i]->ppid = 1; - if (chld_procs[i].wait_thread) -- chld_procs[i].wait_thread->terminate_thread (); -+ if (!CancelSynchronousIo (chld_procs[i].wait_thread->thread_handle ())) -+ chld_procs[i].wait_thread->terminate_thread (); +- if (chld_procs[i].wait_thread) ++ /* Attempt to exit the wait_thread cleanly via CancelSynchronousIo ++ before falling back to the (explicitly dangerous) cross-thread ++ termination */ ++ if (chld_procs[i].wait_thread ++ && !CancelSynchronousIo (chld_procs[i].wait_thread->thread_handle ())) + chld_procs[i].wait_thread->terminate_thread (); /* Release memory associated with this process unless it is 'myself'. 'myself' is only in the chld_procs table when we've execed. We - reach here when the next process has finished initializing but we +@@ winsup/cygwin/sigproc.cc: remove_proc (int ci) + { + if (have_execed) + { +- if (_my_tls._ctinfo != chld_procs[ci].wait_thread) ++ /* Attempt to exit the wait_thread cleanly via CancelSynchronousIo ++ before falling back to the (explicitly dangerous) cross-thread ++ termination */ ++ if (_my_tls._ctinfo != chld_procs[ci].wait_thread ++ && !CancelSynchronousIo (chld_procs[ci].wait_thread->thread_handle ())) + chld_procs[ci].wait_thread->terminate_thread (); + } + else if (chld_procs[ci] && chld_procs[ci]->exists ())65: 395fda6 ! 47: e5dc132 Cygwin: revert use of CancelSyncronousIo on wait_thread.
@@ Commit message as the hangs on ARM64, because `CancelSynchronousIo` is returning `TRUE` but not canceling the `ReadFile` call as expected. - Cherry-picked from msys2/msys2-runtime's 2eb6be14ee (Cygwin: revert use - of CancelSyncronousIo on wait_thread., 2024-11-21). - Addresses: https://github.com/msys2/MSYS2-packages/issues/4340#issuecomment-2491401847 Fixes: b091b47b9e56 ("cygthread: suspend thread before terminating.") Signed-off-by: Jeremy Drake <[email protected]> - Signed-off-by: Johannes Schindelin <[email protected]> ## winsup/cygwin/pinfo.cc ## @@ winsup/cygwin/pinfo.cc: proc_waiter (void *arg) @@ winsup/cygwin/pinfo.cc: proc_waiter (void *arg) - && (err = GetLastError ()) != ERROR_BROKEN_PIPE) + && GetLastError () != ERROR_BROKEN_PIPE) { +- /* ERROR_OPERATION_ABORTED is expected due to the possibility that +- CancelSynchronousIo interruped the ReadFile call, so don't output +- that error */ - if (err != ERROR_OPERATION_ABORTED) - system_printf ("error on read of child wait pipe %p, %E", vchild.rd_proc_pipe); + system_printf ("error on read of child wait pipe %p, %E", vchild.rd_proc_pipe); @@ winsup/cygwin/pinfo.cc: proc_waiter (void *arg) ## winsup/cygwin/sigproc.cc ## @@ winsup/cygwin/sigproc.cc: proc_terminate () + to 1 iff it is a Cygwin process. */ if (!have_execed || !have_execed_cygwin) chld_procs[i]->ppid = 1; - if (chld_procs[i].wait_thread) -- if (!CancelSynchronousIo (chld_procs[i].wait_thread->thread_handle ())) -- chld_procs[i].wait_thread->terminate_thread (); -+ chld_procs[i].wait_thread->terminate_thread (); +- /* Attempt to exit the wait_thread cleanly via CancelSynchronousIo +- before falling back to the (explicitly dangerous) cross-thread +- termination */ +- if (chld_procs[i].wait_thread +- && !CancelSynchronousIo (chld_procs[i].wait_thread->thread_handle ())) ++ if (chld_procs[i].wait_thread) + chld_procs[i].wait_thread->terminate_thread (); /* Release memory associated with this process unless it is 'myself'. 'myself' is only in the chld_procs table when we've execed. We - reach here when the next process has finished initializing but we +@@ winsup/cygwin/sigproc.cc: remove_proc (int ci) + { + if (have_execed) + { +- /* Attempt to exit the wait_thread cleanly via CancelSynchronousIo +- before falling back to the (explicitly dangerous) cross-thread +- termination */ +- if (_my_tls._ctinfo != chld_procs[ci].wait_thread +- && !CancelSynchronousIo (chld_procs[ci].wait_thread->thread_handle ())) ++ if (_my_tls._ctinfo != chld_procs[ci].wait_thread) + chld_procs[ci].wait_thread->terminate_thread (); + } + else if (chld_procs[ci] && chld_procs[ci]->exists ())-: ---------- > 48: 5453f9f Cygwin: cache IsWow64Process2 host arch in wincap.
-: ---------- > 49: 985e265 Cygwin: uname: add host machine tag to sysname.
47: 23958eb ! 50: 3d08a3f Bump actions/checkout from 2 to 4
@@ Commit message Signed-off-by: dependabot[bot] <[email protected]> - ## .github/workflows/build.yaml ## -@@ .github/workflows/build.yaml: jobs: - - steps: - - name: Checkout code -- uses: actions/checkout@v3 -+ uses: actions/checkout@v4 - - - name: setup-msys2 - uses: msys2/setup-msys2@v2 - ## .github/workflows/cygwin.yml ## @@ .github/workflows/cygwin.yml: jobs: HAS_SSH_KEY: ${{ secrets.SSH_KEY != '' }}48: 699c573 = 51: 9fd3157 dependabot: help keeping GitHub Actions versions up to date
49: 76c8b24 = 52: 31f9012 Do not try to sync with Cygwin
50: 3cf583c = 53: cac55e8 Handle 8-bit characters under LOCALE=C
51: 51d19bb = 54: 6990ce7 Mention the extremely useful small_printf() function
52: 885c2fa = 55: 8b2144f Fixed path converting with non ascii char.
53: 70b4715 = 56: e05ee92 Make paths' WCS->MBS conversion explicit
54: 9614377 = 57: 64dfcd6 Allow native symlinks to non-existing targets in 'nativestrict' mode
55: 97cefff = 58: 2ff02fd Use MB_CUR_MAX == 6 by default
56: 0472dec = 59: e1c6154 Change the default base address for x86_64
57: f4fb564 = 60: 9ba6664 msys2-runtime: restore fast path for current user primary group
58: 900a410 (upstream: 68a14b6) < -: ---------- Cygwin: console: Disable cons_master_thread in win32-input-mode
59: 8854bb4 < -: ---------- Cygwin: pipe: Fix a regression that raw_write() slows down
60: 9d0d6e1 (upstream: c7fe29f) < -: ---------- Cygwin: pipe: Restore blocking mode of read pipe on close()/raw_read()
61: cbe555e = 61: 67bdfc7 Fix SSH hangs
64: 54a7252 < -: ---------- fixup! cygthread: suspend thread before terminating.
This closes git-for-windows/git#5326