Skip to content

Commit

Permalink
Merge pull request #49 from dscho/prevent-different-msys2-runtime-ver…
Browse files Browse the repository at this point in the history
…sions-from-sharing-cygheaps-take-two

Prevent different msys2 runtime versions from sharing cygheaps, take two
  • Loading branch information
dscho authored Feb 22, 2023
2 parents 8a2855c + bec3d60 commit 27eb5a5
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 4 deletions.
34 changes: 34 additions & 0 deletions winsup/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,40 @@ AC_CHECK_TOOL(RANLIB, ranlib, ranlib)
AC_CHECK_TOOL(STRIP, strip, strip)
AC_CHECK_TOOL(WINDRES, windres, windres)

# Record msys2-runtime commit
AC_ARG_WITH([msys2-runtime-commit],
[AS_HELP_STRING([--with-msys2-runtime-commit=COMMIT],
[indicate the msys2-runtime commit corresponding to this build])],
[MSYS2_RUNTIME_COMMIT=$withval], [MSYS2_RUNTIME_COMMIT=yes])
case "$MSYS2_RUNTIME_COMMIT" in
no)
MSYS2_RUNTIME_COMMIT=
MSYS2_RUNTIME_COMMIT_SHORT=
MSYS2_RUNTIME_COMMIT_HEX=0
;;
yes|auto)
if MSYS2_RUNTIME_COMMIT="$(git --git-dir="$srcdir/../.git" rev-parse HEAD)"
then
MSYS2_RUNTIME_COMMIT_SHORT="$(expr "$MSYS2_RUNTIME_COMMIT" : '\(.\{,8\}\)')"
MSYS2_RUNTIME_COMMIT_HEX="0x${MSYS2_RUNTIME_COMMIT_SHORT}ul"
else
AC_MSG_WARN([Could not determine msys2-runtime commit"])
MSYS2_RUNTIME_COMMIT=
MSYS2_RUNTIME_COMMIT_SHORT=
MSYS2_RUNTIME_COMMIT_HEX=0
fi
;;
*)
expr "$MSYS2_RUNTIME_COMMIT" : '@<:@0-9a-f@:>@\{6,64\}$' ||
AC_MSG_ERROR([Invalid commit name: "$MSYS2_RUNTIME_COMMIT"])
MSYS2_RUNTIME_COMMIT_SHORT="$(expr "$MSYS2_RUNTIME_COMMIT" : '\(.\{,8\}\)')"
MSYS2_RUNTIME_COMMIT_HEX="0x${MSYS2_RUNTIME_COMMIT_SHORT}ul"
;;
esac
AC_SUBST(MSYS2_RUNTIME_COMMIT)
AC_SUBST(MSYS2_RUNTIME_COMMIT_SHORT)
AC_SUBST(MSYS2_RUNTIME_COMMIT_HEX)

AC_ARG_ENABLE(debugging,
[ --enable-debugging Build a cygwin DLL which has more consistency checking for debugging],
[case "${enableval}" in
Expand Down
7 changes: 6 additions & 1 deletion winsup/cygwin/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ if TARGET_X86_64
COMMON_CFLAGS+=-mcmodel=small
endif

VERSION_CFLAGS = -DMSYS2_RUNTIME_COMMIT="\"@MSYS2_RUNTIME_COMMIT@\""
VERSION_CFLAGS += -DMSYS2_RUNTIME_COMMIT_SHORT="\"@MSYS2_RUNTIME_COMMIT_SHORT@\""
VERSION_CFLAGS += -DMSYS2_RUNTIME_COMMIT_HEX="@MSYS2_RUNTIME_COMMIT_HEX@"
COMMON_CFLAGS += $(VERSION_CFLAGS)

AM_CFLAGS=$(cflags_common) $(COMMON_CFLAGS)
AM_CXXFLAGS=$(cxxflags_common) $(COMMON_CFLAGS) -fno-threadsafe-statics

Expand Down Expand Up @@ -405,7 +410,7 @@ src_files := $(foreach dir,$(dirs),$(find_src_files))
version.cc: mkvers.sh include/cygwin/version.h winver.rc $(src_files)
@echo "Making version.cc and winver.o";\
export CC="$(CC)";\
/bin/sh $(word 1,$^) $(word 2,$^) $(word 3,$^) $(WINDRES) $(CFLAGS)
/bin/sh $(word 1,$^) $(word 2,$^) $(word 3,$^) $(WINDRES) $(CFLAGS) $(VERSION_CFLAGS)

winver.o: version.cc

Expand Down
2 changes: 1 addition & 1 deletion winsup/cygwin/dcrt0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ get_cygwin_startup_info ()
child_info *res = (child_info *) si.lpReserved2;

if (si.cbReserved2 < EXEC_MAGIC_SIZE || !res
|| res->intro != PROC_MAGIC_GENERIC || res->magic != (CHILD_INFO_MAGIC ^ CYGWIN_VERSION_DLL_COMBINED))
|| res->intro != PROC_MAGIC_GENERIC || res->magic != (CHILD_INFO_MAGIC ^ MSYS2_RUNTIME_COMMIT_HEX))
{
strace.activate (false);
res = NULL;
Expand Down
8 changes: 8 additions & 0 deletions winsup/cygwin/mkvers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ incfile="$1"; shift
rcfile="$1"; shift
windres="$1"; shift
iflags=
msys2_runtime_commit=
# Find header file locations
while [ -n "$*" ]; do
case "$1" in
Expand All @@ -26,6 +27,9 @@ while [ -n "$*" ]; do
shift
iflags="$iflags -I$1"
;;
-DMSYS2_RUNTIME_COMMIT=*)
msys2_runtime_commit="${1#*=}"
;;
esac
shift
done
Expand Down Expand Up @@ -185,6 +189,10 @@ then
cvs_tag="$(echo $wv_cvs_tag | sed -e 's/-branch.*//')"
cygwin_ver="$cygwin_ver-$cvs_tag"
fi
if [ -n "$msys2_runtime_commit" ]
then
cygwin_ver="$cygwin_ver-$msys2_runtime_commit"
fi

echo "Version $cygwin_ver"
set -$- $builddate
Expand Down
2 changes: 1 addition & 1 deletion winsup/cygwin/sigproc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ int child_info::retry_count = 0;
by fork/spawn/exec. */
child_info::child_info (unsigned in_cb, child_info_types chtype,
bool need_subproc_ready):
cb (in_cb), intro (PROC_MAGIC_GENERIC), magic (CHILD_INFO_MAGIC ^ CYGWIN_VERSION_DLL_COMBINED),
cb (in_cb), intro (PROC_MAGIC_GENERIC), magic (CHILD_INFO_MAGIC ^ MSYS2_RUNTIME_COMMIT_HEX),
type (chtype), cygheap (::cygheap), cygheap_max (::cygheap_max),
flag (0), retry (child_info::retry_count), rd_proc_pipe (NULL),
wr_proc_pipe (NULL), sigmask (_my_tls.sigmask)
Expand Down
3 changes: 2 additions & 1 deletion winsup/cygwin/uname.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ uname_x (struct utsname *name)
cygwin_gethostname (buf, sizeof buf - 1);
strncat (name->nodename, buf, sizeof (name->nodename) - 1);
/* release */
__small_sprintf (name->release, "%d.%d.%d-%d.",
__small_sprintf (name->release, "%d.%d.%d-%s-%d.",
cygwin_version.dll_major / 1000,
cygwin_version.dll_major % 1000,
cygwin_version.dll_minor,
MSYS2_RUNTIME_COMMIT_SHORT,
cygwin_version.api_minor);
/* version */
stpcpy (name->version, cygwin_version.dll_build_date);
Expand Down

0 comments on commit 27eb5a5

Please sign in to comment.