Skip to content

Commit

Permalink
msys2-runtime-3.3: backport a couple 3.4 patches
Browse files Browse the repository at this point in the history
This corresponds to msys2/msys2-runtime#197.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Feb 11, 2024
1 parent d772b5f commit 7c404fb
Show file tree
Hide file tree
Showing 7 changed files with 320 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From 8148ef7547f1fb8394810f9e24a28ebd2c83a375 Mon Sep 17 00:00:00 2001
From: Takashi Yano <[email protected]>
Date: Thu, 22 Dec 2022 20:25:22 +0900
Subject: [PATCH 51/N] Cygwin: console: Fix hangup of less on quit after the
window is resized.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

https://cygwin.com/pipermail/cygwin/2022-December/252737.html

If the less is started from non-cygwin shell and window size is
changed, it will hang-up when quitting. The cause of the proglem is
that less uses longjump() in signal handler. If the signal handler
is called while cygwin is acquiring the mutex, cygwin loses the
chance to release mutex. With this patch, the mutex is released
just before calling kill_pgrp() and re-acquired when kill_pgrp()
returns.

[ma: dropped changes to release notes file from patch for backport]

Reported-by: Gregory Mason <[email protected]>
Signed-off-by: Takashi Yano <[email protected]>
Signed-off-by: Matthias Aßhauer <[email protected]>
---
winsup/cygwin/fhandler_console.cc | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index b5594a6..e3a42ac 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -937,7 +937,11 @@ fhandler_console::send_winch_maybe ()
con.scroll_region.Bottom = -1;
if (wincap.has_con_24bit_colors () && !con_is_legacy)
fix_tab_position (get_output_handle ());
+ /* longjmp() may be called in the signal handler like less,
+ so release input_mutex temporarily before kill_pgrp(). */
+ release_input_mutex ();
get_ttyp ()->kill_pgrp (SIGWINCH);
+ acquire_input_mutex (mutex_timeout);
return true;
}
return false;
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From b00763c145a60347e6cb41a1b5876e08e09887a7 Mon Sep 17 00:00:00 2001
From: Johannes Schindelin <[email protected]>
Date: Fri, 12 May 2023 13:37:56 +0200
Subject: [PATCH 52/N] Adjust CWD magic to accommodate for the latest Windows
previews

Reportedly Windows 11 build 25*** from Insider changed the current
working directory logic a bit, and Cygwin's "magic" (or:
"technologically sufficiently advanced") code needs to be adjusted
accordingly.

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

Signed-off-by: Johannes Schindelin <[email protected]>
---
winsup/cygwin/path.cc | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index e191b9e..27e203b 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -4873,10 +4873,24 @@ find_fast_cwd_pointer ()
or, then `mov %r12,%rcx', then `callq RtlEnterCriticalSection'. */
lock = (const uint8_t *) memmem ((const char *) use_cwd, 80,
"\x4c\x8d\x25", 3);
- if (!lock)
- return NULL;
call_rtl_offset = 14;
}
+
+ if (!lock)
+ {
+ /* A recent Windows Preview calls `lea rel(rip),%r13' then
+ some unrelated instructions, then `callq RtlEnterCriticalSection'.
+ */
+ lock = (const uint8_t *) memmem ((const char *) use_cwd, 80,
+ "\x4c\x8d\x2d", 3);
+ call_rtl_offset = 24;
+ }
+
+ if (!lock)
+ {
+ return NULL;
+ }
+
PRTL_CRITICAL_SECTION lockaddr =
(PRTL_CRITICAL_SECTION) (lock + 7 + peek32 (lock + 3));
/* Test if lock address is FastPebLock. */
25 changes: 25 additions & 0 deletions msys2-runtime-3.3/0053-CI-fix-the-build-with-gcc-13.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 99b8001f7d6456cddd4db254016321e4e9449353 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <[email protected]>
Date: Fri, 10 Nov 2023 15:31:10 +0100
Subject: [PATCH 53/N] CI: fix the build with gcc 13

---
.github/workflows/build.yaml | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 1775bb9..f89cfcb 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -20,6 +20,11 @@ jobs:
- name: Build
shell: msys2 {0}
run: |
+ # XXX: cygwin still uses gcc v11 so we get new warnings with v13,
+ # resulting in errors. We can't selectively disable warnigns since our
+ # cross compiler is also too old and doesn't understand the new
+ # warning flags, so we need to disable all errors for now.
+ export CXXFLAGS="-Wno-error -Wno-narrowing"
(cd winsup && ./autogen.sh)
./configure --disable-dependency-tracking
make -j8
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From b9149f75436c8a912e3edbcae9f66324e596f151 Mon Sep 17 00:00:00 2001
From: Kai Pastor <[email protected]>
Date: Tue, 21 Nov 2023 09:24:03 +0100
Subject: [PATCH 54/N] fixup! Add functionality for converting UNIX paths in
arguments and environment variables to Windows form for native Win32
applications.

Don't memchr behind end, it+1
---
winsup/cygwin/msys2_path_conv.cc | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc
index ebf47d6..e6f8f7c 100644
--- a/winsup/cygwin/msys2_path_conv.cc
+++ b/winsup/cygwin/msys2_path_conv.cc
@@ -346,6 +346,13 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en

path_type result = NONE;

+ if (it + 1 == end) {
+ switch (*it) {
+ case '/': return ROOTED_PATH ;
+ default: return SIMPLE_WINDOWS_PATH;
+ }
+ }
+
if (isalpha(*it) && *(it + 1) == ':') {
if (*(it + 2) == '\\') {
return SIMPLE_WINDOWS_PATH;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 6a4927f2daba82f3a08ffb68c342394a33e68944 Mon Sep 17 00:00:00 2001
From: Kai Pastor <[email protected]>
Date: Tue, 21 Nov 2023 09:25:58 +0100
Subject: [PATCH 55/N] fixup! Add functionality for converting UNIX paths in
arguments and environment variables to Windows form for native Win32
applications.

Don't memchr behind end, it2
---
winsup/cygwin/msys2_path_conv.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc
index e6f8f7c..68cd6cc 100644
--- a/winsup/cygwin/msys2_path_conv.cc
+++ b/winsup/cygwin/msys2_path_conv.cc
@@ -428,7 +428,7 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en
if (isalpha(ch) && (*(it2+1) == ':') && (*(it2+2) == '/')) {
return SIMPLE_WINDOWS_PATH;
}
- if (ch == '/'&& memchr(it2, ',', end - it) == NULL) {
+ if (ch == '/'&& memchr(it2, ',', end - it2) == NULL) {
*src = it2;
return find_path_start_and_type(src, true, end);
}
@@ -455,7 +455,7 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en
} else {
return POSIX_PATH_LIST;
}
- } else if (memchr(it2, '=', end - it) == NULL) {
+ } else if (memchr(it2, '=', end - it2) == NULL) {
return SIMPLE_WINDOWS_PATH;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
From 3cba82a63c4f3a8c10565ab531fb64a5d2117474 Mon Sep 17 00:00:00 2001
From: Johannes Schindelin <[email protected]>
Date: Sat, 25 Nov 2023 02:25:00 +0100
Subject: [PATCH 56/N] nlsfuncs: work around an overzealous GCC warning

GCC 13 (and maybe 12, too), warn about pointers used after `free()`.

In `nlsfuncs.cc`, they are used on purpose, though, in
`rebase_locale_buf()`, to adjust pointers that were invalidated because
of a `realloc()` (not a `free()`, actually).

So let's shush GCC about those instances.

However, we must be careful only to do that with GCC >= 12 because older
versions would complain about an unknown warning...

Signed-off-by: Johannes Schindelin <[email protected]>
---
winsup/cygwin/nlsfuncs.cc | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

diff --git a/winsup/cygwin/nlsfuncs.cc b/winsup/cygwin/nlsfuncs.cc
index a518d2b..0d1e692 100644
--- a/winsup/cygwin/nlsfuncs.cc
+++ b/winsup/cygwin/nlsfuncs.cc
@@ -255,8 +255,13 @@ rebase_locale_buf (const void *ptrv, const void *ptrvend, const char *newbase,
{
const char **ptrsend = (const char **) ptrvend;
for (const char **ptrs = (const char **) ptrv; ptrs < ptrsend; ++ptrs)
+#pragma GCC diagnostic push
+#if __GNUC__ >= 12
+#pragma GCC diagnostic ignored "-Wuse-after-free"
+#endif
if (*ptrs >= oldbase && *ptrs < oldend)
*ptrs += newbase - oldbase;
+#pragma GCC diagnostic pop
}

static wchar_t *
@@ -613,10 +618,15 @@ __set_lc_time_from_win (const char *name,
era = NULL;
else
{
+#pragma GCC diagnostic push
+#if __GNUC__ >= 12
+#pragma GCC diagnostic ignored "-Wuse-after-free"
+#endif
if (tmp != new_lc_time_buf)
rebase_locale_buf (_time_locale, _time_locale + 1, tmp,
new_lc_time_buf, lc_time_ptr);
lc_time_ptr = tmp + (lc_time_ptr - new_lc_time_buf);
+#pragma GCC diagnostic pop
new_lc_time_buf = tmp;
lc_time_end = new_lc_time_buf + len;
}
@@ -675,9 +685,14 @@ __set_lc_time_from_win (const char *name,
free (new_lc_time_buf);
return -1;
}
+#pragma GCC diagnostic push
+#if __GNUC__ >= 12
+#pragma GCC diagnostic ignored "-Wuse-after-free"
+#endif
if (tmp != new_lc_time_buf)
rebase_locale_buf (_time_locale, _time_locale + 1, tmp,
new_lc_time_buf, lc_time_ptr);
+#pragma GCC diagnostic pop
*lc_time_buf = tmp;
return 1;
}
@@ -747,9 +762,14 @@ __set_lc_ctype_from_win (const char *name,
free (new_lc_ctype_buf);
return -1;
}
+#pragma GCC diagnostic push
+#if __GNUC__ >= 12
+#pragma GCC diagnostic ignored "-Wuse-after-free"
+#endif
if (tmp != new_lc_ctype_buf)
rebase_locale_buf (_ctype_locale, _ctype_locale + 1, tmp,
new_lc_ctype_buf, lc_ctype_ptr);
+#pragma GCC diagnostic pop
*lc_ctype_buf = tmp;
return 1;
}
@@ -822,9 +842,14 @@ __set_lc_numeric_from_win (const char *name,
free (new_lc_numeric_buf);
return -1;
}
+#pragma GCC diagnostic push
+#if __GNUC__ >= 12
+#pragma GCC diagnostic ignored "-Wuse-after-free"
+#endif
if (tmp != new_lc_numeric_buf)
rebase_locale_buf (_numeric_locale, _numeric_locale + 1, tmp,
new_lc_numeric_buf, lc_numeric_ptr);
+#pragma GCC diagnostic pop
*lc_numeric_buf = tmp;
return 1;
}
@@ -959,9 +984,14 @@ __set_lc_monetary_from_win (const char *name,
free (new_lc_monetary_buf);
return -1;
}
+#pragma GCC diagnostic push
+#if __GNUC__ >= 12
+#pragma GCC diagnostic ignored "-Wuse-after-free"
+#endif
if (tmp != new_lc_monetary_buf)
rebase_locale_buf (_monetary_locale, _monetary_locale + 1, tmp,
new_lc_monetary_buf, lc_monetary_ptr);
+#pragma GCC diagnostic pop
*lc_monetary_buf = tmp;
return 1;
}
28 changes: 23 additions & 5 deletions msys2-runtime-3.3/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pkgbase=msys2-runtime-3.3
pkgname=('msys2-runtime-3.3' 'msys2-runtime-3.3-devel')
pkgver=3.3.6
pkgrel=6
pkgrel=7
pkgdesc="Cygwin POSIX emulation engine"
arch=('i686' 'x86_64')
url="https://www.cygwin.com/"
Expand Down Expand Up @@ -74,7 +74,13 @@ source=('msys2-runtime'::git://sourceware.org/git/newlib-cygwin.git#tag=cygwin-$
0047-dumper-avoid-linker-problem-when-libbfd-depends-on-l.patch
0048-CI-build-with-disable-dependency-tracking.patch
0049-Stop-assuming-that-there-are-no-spaces-in-POSIX-styl.patch
0050-Cygwin-Fix-compiling-with-w32api-headers-v11.0.0.patch)
0050-Cygwin-Fix-compiling-with-w32api-headers-v11.0.0.patch
0051-Cygwin-console-Fix-hangup-of-less-on-quit-after-the-.patch
0052-Adjust-CWD-magic-to-accommodate-for-the-latest-Windo.patch
0053-CI-fix-the-build-with-gcc-13.patch
0054-fixup-Add-functionality-for-converting-UNIX-paths-in.patch
0055-fixup-Add-functionality-for-converting-UNIX-paths-in.patch
0056-nlsfuncs-work-around-an-overzealous-GCC-warning.patch)
sha256sums=('SKIP'
'c375315e58181ee5589b7966101aa095de3f864a579c3c3f0f0683595d4e428d'
'01ea2b131cf5a3b27fdbc458019eac14e45a36782ce3ce33e62328eefcd2d02e'
Expand Down Expand Up @@ -125,7 +131,13 @@ sha256sums=('SKIP'
'5647a4675b1f1f7c0a221f077d1d892c3e6bdb0635b2b23563838fe8ebfe0637'
'c209bb6147094390e71d024367859f04e112eb2c90cbb289b24c4903224b2ae8'
'5e690151d40a180138e198b19200b2e9840a9d4510da21896b027dc6b8e47f7d'
'b37dbd1f70b3843a9917d4ec19bb57b1003893ccba79bbc5881ef3753838d8e4')
'b37dbd1f70b3843a9917d4ec19bb57b1003893ccba79bbc5881ef3753838d8e4'
'37019d648c72147173a847212d77241d3a9e6e4ae458f50587f60106a761061e'
'9b0e31682c86d4f61677413f7a536bed04d631471d009dd4351c53e0b2f5c9e5'
'8024edf0bcce8900061fae947bb46b4c3fbdea09d327a3c6048e0af292c8e991'
'bf366ac49fb1c4e9d6d16eb38267cf04cf12a1ca510bd7d1ddfc0b834146c295'
'168025561b2d0150e40509bd028545dc0e7af4ae1dbca7aa9b8f37da801e37e3'
'6d985b7f92307cbe376af31fa1fc8010e2dc56e1354938b13423d4da06bc1d6c')

# Helper macros to help make tasks easier #
apply_patch_with_msg() {
Expand Down Expand Up @@ -212,7 +224,13 @@ prepare() {
0047-dumper-avoid-linker-problem-when-libbfd-depends-on-l.patch \
0048-CI-build-with-disable-dependency-tracking.patch \
0049-Stop-assuming-that-there-are-no-spaces-in-POSIX-styl.patch \
0050-Cygwin-Fix-compiling-with-w32api-headers-v11.0.0.patch
0050-Cygwin-Fix-compiling-with-w32api-headers-v11.0.0.patch \
0051-Cygwin-console-Fix-hangup-of-less-on-quit-after-the-.patch \
0052-Adjust-CWD-magic-to-accommodate-for-the-latest-Windo.patch \
0053-CI-fix-the-build-with-gcc-13.patch \
0054-fixup-Add-functionality-for-converting-UNIX-paths-in.patch \
0055-fixup-Add-functionality-for-converting-UNIX-paths-in.patch \
0056-nlsfuncs-work-around-an-overzealous-GCC-warning.patch
}

build() {
Expand All @@ -230,7 +248,7 @@ build() {
fi

CFLAGS="$OPTIM -pipe -ggdb -Wno-error=deprecated -Wno-error=stringop-truncation -Wno-error=missing-attributes -Wno-error=maybe-uninitialized" #-Wno-error=class-memaccess
CXXFLAGS="$OPTIM -pipe -ggdb -Wno-error=deprecated -Wno-error=stringop-truncation -Wno-error=missing-attributes -Wno-error=maybe-uninitialized" #-Wno-error=class-memaccess
CXXFLAGS="$OPTIM -pipe -ggdb -Wno-error=deprecated -Wno-error=stringop-truncation -Wno-error=missing-attributes -Wno-error=maybe-uninitialized -Wno-error=overloaded-virtual" #-Wno-error=class-memaccess

(cd "${srcdir}/msys2-runtime/winsup" && ./autogen.sh)

Expand Down

0 comments on commit 7c404fb

Please sign in to comment.