Skip to content

Commit 65ce633

Browse files
committed
Avoid sharing cygheaps across Cygwin versions
It frequently leads to problems when trying, say, to call from Git for Windows' Bash into Cygwin's or MSYS2's, merely because sharing that data is pretty finicky. For example, using the Git for Windows that is current at time of writing, trying to call MSYS2's Bash from Git for Windows' Bash fails somewhere in `_cmalloc()`, without any error message, and with the rather misleading exit code 127 (a code which is reserved to indicate that a command was not found). Let's just treat these as completely incompatible with one another, by virtue of using a different `CHILD_INFO_MAGIC` constant. One consequence is that spawned MSYS processes using a different MSYS2 runtime will not be visible as such to the parent process, i.e. they cannot share any resources such as pseudo terminals. But that's okay, they are simply treated as if they were regular Win32 programs. This should also help the scenario where interactions between two different versions of Git for Windows lead to those infamous `cygheap base mismatch detected` problems mentioned e.g. in git-for-windows/git#4255 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 54f02c5 commit 65ce633

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

winsup/cygwin/dcrt0.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ get_cygwin_startup_info ()
545545
child_info *res = (child_info *) si.lpReserved2;
546546

547547
if (si.cbReserved2 < EXEC_MAGIC_SIZE || !res
548-
|| res->intro != PROC_MAGIC_GENERIC || res->magic != CHILD_INFO_MAGIC)
548+
|| res->intro != PROC_MAGIC_GENERIC || res->magic != (CHILD_INFO_MAGIC ^ CYGWIN_VERSION_DLL_COMBINED))
549549
{
550550
strace.activate (false);
551551
res = NULL;

winsup/cygwin/sigproc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ int child_info::retry_count = 0;
817817
by fork/spawn/exec. */
818818
child_info::child_info (unsigned in_cb, child_info_types chtype,
819819
bool need_subproc_ready):
820-
cb (in_cb), intro (PROC_MAGIC_GENERIC), magic (CHILD_INFO_MAGIC),
820+
cb (in_cb), intro (PROC_MAGIC_GENERIC), magic (CHILD_INFO_MAGIC ^ CYGWIN_VERSION_DLL_COMBINED),
821821
type (chtype), cygheap (::cygheap), cygheap_max (::cygheap_max),
822822
flag (0), retry (child_info::retry_count), rd_proc_pipe (NULL),
823823
wr_proc_pipe (NULL), sigmask (_my_tls.sigmask)

0 commit comments

Comments
 (0)