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

Prevent different msys2 runtime versions from sharing cygheaps, take two #49

Conversation

dscho
Copy link
Member

@dscho dscho commented Feb 21, 2023

This is a follow-up for #48 designed to address part of git-for-windows/git#4305 by encoding the msys2-runtime commit in the magic constant used to figure out whether we can use "another MSYS2 runtime"'s cygheap or not.

At least in this developer's tests, adding the git-sdk-64's usr/bin to the PATH and fixed the exit code 127 seen when running & 'C:\Program Files\Git\usr\bin\tar.exe' tzvf .\x.tgz in a PowerShell.

@dscho dscho self-assigned this Feb 21, 2023
@dscho dscho force-pushed the prevent-different-msys2-runtime-versions-from-sharing-cygheaps-take-two branch from 06a54cb to 88ca9fd Compare February 21, 2023 16:15
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.

Let's take the msys2-runtime commit as the tell-tale whether two MSYS2
runtime versions are compatible with each other. To support building in
the MSYS2-packages repository (where we do not check out the
`msys2-runtime` but instead check out Cygwin and apply patches on top),
let's accept a hard-coded commit hash as `./configure` option.

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

Note: We have to use a very rare form of encoding the brackets in the
`expr` calls: quadrigraphs (for a thorough explanation, see
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/Quadrigraphs.html#Quadrigraphs).
This is necessary because it is apparently impossible in `configure.ac`
files to encode brackets otherwise.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Having just Cygwin's version in the output of `uname` is not helpful as
both MSYS2 as well as Git for Windows release intermediate versions of
the MSYS2 runtime much more often than Cygwin runtime versions are
released.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho force-pushed the prevent-different-msys2-runtime-versions-from-sharing-cygheaps-take-two branch from 88ca9fd to bec3d60 Compare February 21, 2023 16:20
dscho added a commit to dscho/MSYS2-packages that referenced this pull request Feb 21, 2023
With this change, we prepare the `./configure` call to make use of the
new feature of the MSYS2 runtime to report the current msys2-runtime
commit, and also to use it when determining whether another MSYS2
runtime instance's cygheap is compatible with the current MSYS2 runtime.

This requires git-for-windows/msys2-runtime#49
patches to be brought into MSYS2-packages before it has any effect.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/MSYS2-packages that referenced this pull request Feb 21, 2023
This brings the patches of
git-for-windows/msys2-runtime#49 into
MSYS2-packages.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/MSYS2-packages that referenced this pull request Feb 21, 2023
With this change, we prepare the `./configure` call to make use of the
new feature of the MSYS2 runtime to report the current msys2-runtime
commit, and also to use it when determining whether another MSYS2
runtime instance's cygheap is compatible with the current MSYS2 runtime.

This requires git-for-windows/msys2-runtime#49
patches to be brought into MSYS2-packages before it has any effect.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/MSYS2-packages that referenced this pull request Feb 21, 2023
This brings the patches of
git-for-windows/msys2-runtime#49 into
MSYS2-packages.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho marked this pull request as ready for review February 21, 2023 22:08
@dscho dscho merged commit 27eb5a5 into git-for-windows:main Feb 22, 2023
@dscho dscho deleted the prevent-different-msys2-runtime-versions-from-sharing-cygheaps-take-two branch February 22, 2023 08:14
dscho added a commit to dscho/msys2-runtime that referenced this pull request May 12, 2023
…ys2-runtime-versions-from-sharing-cygheaps-take-two

Prevent different msys2 runtime versions from sharing cygheaps, take two
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant