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 #192

Conversation

dscho
Copy link
Collaborator

@dscho dscho commented Jan 30, 2024

This allows users to run Cygwin programs from an MSYS2 Bash even when the MSYS2 runtime version corresponds to the Cygwin runtime version used by those Cygwin programs.

Incidentally, it also allows calling Git for Windows' Bash from the MSYS2 Bash.

It frequently leads to problems when trying, say, to call from MSYS2's
Bash into Cygwin's or Git for Windows', merely because sharing that data
is pretty finicky.

For example, using the MSYS2' Bash using the MSYS2 runtime version that
is current at time of writing, trying to call Cygwin's programs fails
in manners like this:

    $ /c/cygwin64/bin/uname -r
      0 [main] uname (9540) child_copy: cygheap read copy failed, 0x800000000..0x800010BE0, done 0, windows pid 9540, Win32 error 6
    680 [main] uname 880 C:\cygwin64\bin\uname.exe: *** fatal error - couldn't create signal pipe, Win32 error 5

with the rather misleading exit code 127 (a code which is reserved to
indicate that a command was not found).

Let's just treat the MSYS2 runtime and the Cygwin runtime as completely
incompatible with one another, by virtue of using a different
magic constant than merely `CHILD_INFO_MAGIC`.

By using the msys2-runtime commit to modify that magic constant, we can
even spawn programs using a different MSYS2 runtime (such as Git for
Windows') because the commit serves 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.

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 to encode brackets
in `configure.ac` files otherwise.

Signed-off-by: Johannes Schindelin <[email protected]>
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 <[email protected]>
@dscho dscho self-assigned this Jan 30, 2024
@dscho
Copy link
Collaborator Author

dscho commented Feb 18, 2024

@lazka @Biswa96 @jeremyd2019 any thoughts whether to merge this now, or hold off until after switching to MSYS2 runtime v3.5.0?

@dscho
Copy link
Collaborator Author

dscho commented Feb 19, 2024

@Biswa96 was that a 👍 for merging now, or a 👍 for holding off until v3.5.0?

@lazka
Copy link
Member

lazka commented Feb 19, 2024

I'd prefer to wait a bit

@Biswa96
Copy link
Member

Biswa96 commented Feb 20, 2024

I can not see any potential issue with this change. So, 👍 for merging it.

@lazka
Copy link
Member

lazka commented Jul 6, 2024

I'm fine with merging this, still ok?

@dscho dscho merged commit 6a58317 into msys2:msys2-3.4.10 Jul 8, 2024
1 check passed
@dscho dscho deleted the prevent-different-msys2-runtime-versions-from-sharing-cygheaps branch July 8, 2024 07:42
dscho added a commit to dscho/MSYS2-packages that referenced this pull request Jul 8, 2024
Looks like we haven't updated `MSYS2-packages`' `msys2-runtime-3.4`
directory in quite a while. This roll-up integrates:

- msys2/msys2-runtime#205
- msys2/msys2-runtime#209
- msys2/msys2-runtime#210
- msys2/msys2-runtime#192

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/MSYS2-packages that referenced this pull request Jul 9, 2024
Looks like we haven't updated `MSYS2-packages`' `msys2-runtime-3.4`
directory in quite a while. This roll-up integrates:

- msys2/msys2-runtime#192
- msys2/msys2-runtime#205
- msys2/msys2-runtime#209
- msys2/msys2-runtime#210
- msys2/msys2-runtime#220

Signed-off-by: Johannes Schindelin <[email protected]>
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.

3 participants