Skip to content
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

Avoid sharing cygheaps across Cygwin versions #48

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions winsup/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ AC_CHECK_LIB([bfd], [bfd_init], [true],

AM_CONDITIONAL(BUILD_DUMPER, [test "x$ac_cv_lib_bfd_bfd_init" = "xyes"])

AC_CHECK_LIB([sframe], [sframe_decode],
AC_MSG_NOTICE([Detected libsframe; Assuming that libbfd depends on it]), [true])

AM_CONDITIONAL(HAVE_LIBSFRAME, [test "x$ac_cv_lib_sframe_sframe_decode" = "xyes"])

AC_CONFIG_FILES([
Makefile
cygwin/Makefile
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)
|| res->intro != PROC_MAGIC_GENERIC || res->magic != (CHILD_INFO_MAGIC ^ CYGWIN_VERSION_DLL_COMBINED))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was surprised at first at the use of bitwise XOR here, as I would expect this to be a bitwise OR if these were flags. However, CYGWIN_VERSION_DLL_COMBINED is an integer with multiple bits (currently set to 3003006 to represent 3.3.6).

So this "magic" is very magical, it seems (and you do a similar update in sigproc.cc.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the commit message motivates this well, saying that we should use a new magic value whenever Git for Windows' version of MSYS2 is updated. (It's not accurate that only a new Git version would change this magic, but if two Git for Windows releases have the identical MSYS2 version, then they should be compatible still.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. The idea here is to have some kind of unique identifier that won't ever be shared between different MSYS2 runtime versions. Hence the XOR (because the OR would decrease the entropy).

{
strace.activate (false);
res = NULL;
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),
cb (in_cb), intro (PROC_MAGIC_GENERIC), magic (CHILD_INFO_MAGIC ^ CYGWIN_VERSION_DLL_COMBINED),
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
4 changes: 4 additions & 0 deletions winsup/utils/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ profiler_CXXFLAGS = -I$(srcdir) -idirafter ${top_srcdir}/cygwin -idirafter ${top
profiler_LDADD = $(LDADD) -lntdll
cygps_LDADD = $(LDADD) -lpsapi -lntdll

if HAVE_LIBSFRAME
dumper_LDADD += -lsframe
endif

if CROSS_BOOTSTRAP
SUBDIRS = mingw
endif