www.fgks.org   »   [go: up one dir, main page]

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

Best way to "run git for windows in wine" or "how to make use of git within pip from python under wine" #3478

Open
mcfreis opened this issue Oct 18, 2021 · 49 comments

Comments

@mcfreis
Copy link
mcfreis commented Oct 18, 2021

As described in the subject, I'm in need of a git client under wine. I use wine with python 3.7 and pip to build python applications for Windows on a Linux host.

I tried the MinGit-2.33.1-64-bit.zip and the Installer-Version and the Portable one but without success.

Do you have any suggestions?

root@c37c06cb132c:~# wine --version
wine-5.0.3 (Debian 5.0.3-3)

Example error:

 > [2/3] RUN wine git -c http.sslVerify=false clone ssh://git@gitlab-prod.****:2222/rnd-team/pytools/srmocklab.git:
#5 1.230 wine: Unhandled page fault on write access to 0000000000000000 at address 00000001402616EB (thread 002d), starting debugger...
#5 1.370 002f:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
#5 1.370 002f:err:winediag:nodrv_CreateWindow Make sure that your X server is running and that $DISPLAY is set correctly.
#5 1.628 Unhandled exception: page fault on write access to 0x00000000 in 64-bit code (0x00000001402616eb).
#5 1.669 Register dump:
#5 1.669  rip:00000001402616eb rsp:000000000032f5a0 rbp:00000000000000d9 eflags:00010246 (  R- --  I  Z- -P- )
#5 1.669  rax:0000000000000000 rbx:0000000000000000 rcx:0000000000000000 rdx:0000000000000000
#5 1.669  rsi:00000002a77ec020 rdi:00000002a77ec020  r8:000000000032f210  r9:00000000000003fe r10:0000000000000008
#5 1.669  r11:0000000000000246 r12:0000000000000000 r13:0000000000550818 r14:0000000000000006 r15:00000000005506d8
#5 1.669 Stack dump:
#5 1.670 0x000000000032f5a0:  0000000000000004 0000000000000001
#5 1.670 0x000000000032f5b0:  000000000032f5e0 00000000000003fe
#5 1.671 0x000000000032f5c0:  000000000032f5dc 0000000000000000
#5 1.671 0x000000000032f5d0:  000000000000000a 000000100001c041
#5 1.671 0x000000000032f5e0:  0000000000000000 0000000000000000
#5 1.672 0x000000000032f5f0:  0000000000000000 0000000000000000
#5 1.672 0x000000000032f600:  0000000000000000 0000000000001000
#5 1.673 0x000000000032f610:  0000000000000000 00000000616d6860
#5 1.673 0x000000000032f620:  00000000259d8ae4 00000000616d6860
#5 1.673 0x000000000032f630:  00000000259d8ae4 00000000616d6860
#5 1.674 0x000000000032f640:  000000003817c464 0000000000000000
#5 1.674 0x000000000032f650:  0000000000000000 0000000000000000
#5 1.674 Backtrace:
#5 1.674 =>0 0x00000001402616eb in git (+0x2616eb) (0x00000000000000d9)
#5 1.674   1 0x0000000140262527 in git (+0x262526) (0x00000000000000d9)
#5 1.674   2 0x000000014026045a in git (+0x260459) (0x00000000000000d9)
#5 1.674   3 0x00000001400013d4 in git (+0x13d3) (0x0000000000550498)
#5 1.674   4 0x0000000140001506 in git (+0x1505) (0x000000000032ffd0)
#5 1.674   5 0x000000007b459c1b __wine_start_process+0x1ea() in kernel32 (0x000000000032ffd0)
#5 1.675 0x00000001402616eb: movw       %dx,(%r12,%rax,2)
#5 1.675 Modules:
#5 1.675 Module Address                                 Debug info      Name (44 modules)
#5 1.675 ELF            7b000000-        7b0e3000       Deferred        kernelbase<elf>
#5 1.675   \-PE         7b010000-        7b0e3000       \               kernelbase
#5 1.675 ELF            7b400000-        7b68a000       Dwarf           kernel32<elf>
#5 1.675   \-PE         7b420000-        7b68a000       \               kernel32
#5 1.675 ELF            7bc00000-        7befb000       Deferred        ntdll<elf>
#5 1.675   \-PE         7bc20000-        7befb000       \               ntdll
#5 1.675 ELF            7c000000-        7c005000       Deferred        <wine-loader>
#5 1.675 PE            140000000-       140388000       Export          git
#5 1.675 PE            214d20000-       214e2b000       Deferred        libiconv-2
#5 1.675 PE            2209f0000-       220a18000       Deferred        libintl-8
#5 1.675 PE            2330a0000-       23313e000       Deferred        libpcre2-8-0
#5 1.675 PE            241b90000-       241bb4000       Deferred        zlib1
#5 1.675 PE            2a77e0000-       2a77f2000       Deferred        libssp-0
#5 1.675 ELF        7fa0e7eb1000-    7fa0e7ed8000       Deferred        imm32<elf>
#5 1.675   \-PE     7fa0e7ec0000-    7fa0e7ed8000       \               imm32
#5 1.675 ELF        7fa0e7ed8000-    7fa0e7ee1000       Deferred        libuuid.so.1
#5 1.675 ELF        7fa0e7ee1000-    7fa0e7f10000       Deferred        libexpat.so.1
#5 1.675 ELF        7fa0e7f10000-    7fa0e7f56000       Deferred        libfontconfig.so.1
#5 1.675 ELF        7fa0e7f56000-    7fa0e7f79000       Deferred        libbrotlicommon.so.1
#5 1.675 ELF        7fa0e7f79000-    7fa0e7f87000       Deferred        libbrotlidec.so.1
#5 1.675 ELF        7fa0e7f87000-    7fa0e7fa4000       Deferred        libz.so.1
#5 1.676 ELF        7fa0e7fa4000-    7fa0e7fde000       Deferred        libpng16.so.16
#5 1.676 ELF        7fa0e7fde000-    7fa0e80a1000       Deferred        libfreetype.so.6
#5 1.676 ELF        7fa0e80a1000-    7fa0e80e5000       Deferred        ws2_32<elf>
#5 1.676   \-PE     7fa0e80b0000-    7fa0e80e5000       \               ws2_32
#5 1.676 ELF        7fa0e80e5000-    7fa0e80fc000       Deferred        version<elf>
#5 1.676   \-PE     7fa0e80f0000-    7fa0e80fc000       \               version
#5 1.676 ELF        7fa0e80fc000-    7fa0e82b5000       Deferred        gdi32<elf>
#5 1.676   \-PE     7fa0e8110000-    7fa0e82b5000       \               gdi32
#5 1.676 ELF        7fa0e82b5000-    7fa0e854d000       Deferred        user32<elf>
#5 1.676   \-PE     7fa0e82e0000-    7fa0e854d000       \               user32
#5 1.676 ELF        7fa0e854d000-    7fa0e85e9000       Deferred        advapi32<elf>
#5 1.676   \-PE     7fa0e8560000-    7fa0e85e9000       \               advapi32
#5 1.676 ELF        7fa0e86e9000-    7fa0e87db000       Deferred        msvcrt<elf>
#5 1.676   \-PE     7fa0e8710000-    7fa0e87db000       \               msvcrt
#5 1.676 ELF        7fa0e89db000-    7fa0e89ef000       Deferred        libnss_files.so.2
#5 1.676 ELF        7fa0e8bef000-    7fa0e8c17000       Deferred        liblzma.so.5
#5 1.676 ELF        7fa0e8c17000-    7fa0e8c31000       Deferred        libgcc_s.so.1
#5 1.676 ELF        7fa0e8c31000-    7fa0e8d75000       Deferred        libm.so.6
#5 1.676 ELF        7fa0e8d75000-    7fa0e8d90000       Deferred        libunwind.so.8
#5 1.676 ELF        7fa0e8d92000-    7fa0e8d98000       Deferred        libdl.so.2
#5 1.676 ELF        7fa0e8d98000-    7fa0e8f5d000       Deferred        libc.so.6
#5 1.676 ELF        7fa0e8f5d000-    7fa0e8f7f000       Deferred        libpthread.so.0
#5 1.676 ELF        7fa0e912d000-    7fa0e915a000       Deferred        ld-linux-x86-64.so.2
#5 1.676 Threads:
#5 1.716 process  tid      prio (all id:s are in hex)
#5 1.740 0000000c winemenubuilder.exe
#5 1.740        0000000d    0
#5 1.764 0000000e services.exe
#5 1.764        0000000f    0
#5 1.764        00000010    0
#5 1.764        00000015    0
#5 1.765        00000016    0
#5 1.765        00000017    0
#5 1.765        0000001d    0
#5 1.765        00000021    0
#5 1.766        00000026    0
#5 1.791 00000011 explorer.exe
#5 1.791        00000012    0
#5 1.791        0000001c    0
#5 1.791        0000001e    0
#5 1.823 00000013 plugplay.exe
#5 1.823        00000014    0
#5 1.823        00000018    0
#5 1.823        00000019    0
#5 1.871 0000001a winedevice.exe
#5 1.871        0000001b    0
#5 1.871        0000001f    0
#5 1.871        00000020    0
#5 1.871        00000022    0
#5 1.871        00000023    0
#5 1.912 00000024 winedevice.exe
#5 1.912        00000025    0
#5 1.912        00000027    0
#5 1.913        00000028    0
#5 1.957 0000002a git.exe
#5 1.957        0000002b    0
#5 1.957 0000002c (D) C:\mingit\mingw64\bin\git.exe
#5 1.957        0000002d    0 <==
#5 1.957        00000030    0
#5 1.958 System information:
#5 1.958     Wine build: wine-5.0.3 (Debian 5.0.3-3)
#5 1.958     Platform: x86_64
#5 1.958     Version: Windows 7
#5 1.958     Host system: Linux
#5 1.958     Host version: 5.10.16.3-microsoft-standard-WSL2
------
executor failed running [/bin/bash -c wine git -c http.sslVerify=false clone ssh://git@gitlab-prod****:2222/rnd-team/pytools/srmocklab.git]: exit code: 5
@dscho
Copy link
Member
dscho commented Oct 18, 2021

Maybe running with GIT_TRACE or GIT_TRACE2_EVENT might shed more light into this? I could imagine that something is going wrong with ASLR, though.

@mcfreis
Copy link
Author
mcfreis commented Oct 19, 2021

With GIT_TRACE:

root@242fe770ca31:~# GIT_TRACE=true wine git clone ssh://git@gitlab-prod.****:2222/rnd-team/pytools/srmocklab.
git
06:09:01.132606 exec-cmd.c:237          trace: resolved executable dir: C:/mingit/mingw64/bin
06:09:01.133686 git.c:455               trace: built-in: git clone ssh://git@gitlab-prod.****:2222/rnd-team/pytools/srmocklab.git
Cloning into 'srmocklab'...
06:09:01.165115 run-command.c:666       trace: run_command: unset GIT_DIR; GIT_PROTOCOL=version=2 ssh -o SendEnv=GIT_PROTOCOL -p 2222 git@gitlab-prod.**** 'git-upload-pack '\''/rnd-team/pytools/srmocklab.git'\'''
BUG: compat/mingw.c:138: err_win_to_posix() called without an error!

abnormal program termination
root@242fe770ca31:~#

And with GIT_TRACE2_EVENT:

root@242fe770ca31:~# GIT_TRACE2_EVENT=true wine git clone ssh://git@gitlab-prod.****:2222/rnd-team/pytools/srmocklab.git
{"event":"version","sid":"20211019T061036.227597Z-H086aa3a8-P0000002b","thread":"main","time":"2021-10-19T06:10:36.227624Z","file":"common-main.c","line":48,"evt":"2","exe":"2.33.1.windows.1"}
{"event":"start","sid":"20211019T061036.227597Z-H086aa3a8-P0000002b","thread":"main","time":"2021-10-19T06:10:36.227754Z","file":"common-main.c","line":49,"t_abs":0.002166,"argv":["git.exe","clone","ssh://git@gitlab-prod.****:2222/rnd-team/pytools/srmocklab.git"]}
{"event":"data_json","sid":"20211019T061036.227597Z-H086aa3a8-P0000002b","thread":"main","time":"2021-10-19T06:10:36.250496Z","file":"compat/win32/trace2_win32_process_info.c","line":118,"repo":0,"t_abs":0.024905,"t_rel":0.024905,"nesting":1,"category":"process","key":"windows/ancestry","value":["git.exe"]}
{"event":"cmd_name","sid":"20211019T061036.227597Z-H086aa3a8-P0000002b","thread":"main","time":"2021-10-19T06:10:36.250765Z","file":"git.c","line":456,"name":"clone","hierarchy":"clone"}
{"event":"def_repo","sid":"20211019T061036.227597Z-H086aa3a8-P0000002b","thread":"main","time":"2021-10-19T06:10:36.253124Z","file":"repository.c","line":132,"repo":1,"worktree":"Z:/root/srmocklab"}
Cloning into 'srmocklab'...
{"event":"child_start","sid":"20211019T061036.227597Z-H086aa3a8-P0000002b","thread":"main","time":"2021-10-19T06:10:36.285852Z","file":"run-command.c","line":738,"child_id":0,"child_class":"transport/ssh","use_shell":false,"argv":["ssh","-o","SendEnv=GIT_PROTOCOL","-p","2222","git@gitlab-prod.****","git-upload-pack '/rnd-team/pytools/srmocklab.git'"]}
BUG: compat/mingw.c:138: err_win_to_posix() called without an error!
{"event":"error","sid":"20211019T061036.227597Z-H086aa3a8-P0000002b","thread":"main","time":"2021-10-19T06:10:36.286784Z","file":"usage.c","line":279,"msg":"err_win_to_posix() called without an error!","fmt":"err_win_to_posix() called without an error!"}

abnormal program termination
root@242fe770ca31:~#

The commands where run within the built docker image whereas the errors in the first post where run during image creation.

But I still have no clue :-(

@dscho
Copy link
Member
dscho commented Oct 19, 2021

The clue is in the command that fails, ssh. Maybe the problem will reproduce if you call that command directly rather than via git clone.

@rimrul
Copy link
Member
rimrul commented Oct 19, 2021

Ok, you're definitely encountering a different error in those commands with trace output.

It looks to me like one of the CreateProcessW() calls in mingw_spawnve_fd() failed, but the following GetLastError() call returned ERROR_SUCCESS. Since you said you tried the installed version, I assume your wineprefix is set up to emulate at least Vista, right?

@mcfreis
Copy link
Author
mcfreis commented Oct 19, 2021

@rimrul Well it's a different error running the same sort of commands in two different environments a) docker build ... and b) docker run ...

Im running wine from Debian Bullseye .. I'm not sure what Windows Version is emulated?

wine-5.0.3 (Debian 5.0.3-3)

But to the suggestion of @dscho

Running

unset GIT_CONFIG_PARAMETERS GIT_DIR; GIT_PROTOCOL=version=2 ssh -o SendEnv=GIT_PROTOCOL -p 2222 git@gitlab-prod.*** 'git-upload-pack '\''/rnd-team/pytools/tchpy3lib.git'\'''

the output is as follows

Warning: Permanently added '[gitlab-prod.****]:2222,[10.***]:2222' (ECDSA) to the list of known hosts.
000eversion 2
0015agent=git/2.31.1
0013ls-refs=unborn
0019fetch=shallow filter
0012server-option
0017object-format=sha1
0000

and then nothing happens till the connection is closed by the server.

@rimrul
Copy link
Member
rimrul commented Oct 19, 2021

@rimrul Well it's a different error running the same sort of commands in two different environments a) docker build ... and b) docker run ...

Likely two different bugs to chase and two different bugfixes. Probably at least one of them in Wines source.

Im running wine from Debian Bullseye .. I'm not sure what Windows Version is emulated?

wine-5.0.3 (Debian 5.0.3-3)

According to their wiki that's Windows XP, unless configured otherwise. The installer should flat out refuse to install in that environment, though.

@mcfreis
Copy link
Author
mcfreis commented Oct 20, 2021

@rimrul I tried to switch from winxp, to vista and win10 without any differences in the error messages. I used the Git Setup which does not install (unattended install without gui; building a docker image), the Portable version, the MinGit version and the tar.bz2 Archive - all with pretty the same errors.

I tried the following:

root@602217c6ead4:~/build# GIT_TRACE=true wine git -c http.sslVerify=false clone ssh://git@gitlab-prod.****:2222/rnd-team/pytools/tchpy3lib.git
07:58:43.401958 exec-cmd.c:237          trace: resolved executable dir: C:/git/mingw64/bin
07:58:43.403221 git.c:455               trace: built-in: git clone ssh://git@gitlab-prod.****:2222/rnd-team/pytools/tchpy3lib.git
Cloning into 'tchpy3lib'...
07:58:43.436147 run-command.c:666       trace: run_command: unset GIT_CONFIG_PARAMETERS GIT_DIR; GIT_PROTOCOL=version=2 ssh -o SendEnv=GIT_PROTOCOL -p 2222 git@gitlab-prod.**** 'git-upload-pack '\''/rnd-team/pytools/tchpy3lib.git'\'''
BUG: compat/mingw.c:138: err_win_to_posix() called without an error!

and then issued the sub command:

root@602217c6ead4:~/build# unset GIT_CONFIG_PARAMETERS GIT_DIR; GIT_PROTOCOL=version=2 wine ssh -o SendEnv=GIT_PROTOCOL -p 2222 git@gitlab-prod.**** 'git-upload-pack '\''/rnd-team/pytools/tchpy3lib.git'\'''
Cygwin WARNING:
  Couldn't compute FAST_CWD pointer.  This typically occurs if you're using
  an older Cygwin version on a newer Windows.  Please update to the latest
  available Cygwin version from https://cygwin.com/.  If the problem persists,
  please see https://cygwin.com/problems.html

This is with the version "Git-2.33.1-64-bit.tar.bz2" extracted manually. Any ideas?

Should I use "vista" oder "win10" for the emulated setting in wine?

Regards

@dscho
Copy link
Member
dscho commented Oct 20, 2021

Couldn't compute FAST_CWD pointer.

I fear that this has been reported e.g. as https://bugs.winehq.org/show_bug.cgi?id=40528, without any resolution I can see there.

@dscho
Copy link
Member
dscho commented Oct 20, 2021

It looks as if TBBle/MSYS2-packages@375689d has a potential fix, I have no idea where this patch was/is on the way into MSYS2 or Cygwin, and honestly, this is such an edge case that I can't justify working on it more than I have.

@mcfreis feel free to take it from here, rebuilding the MSYS2 runtime.

You can easily rebuild the MSYS2 runtime via GitHub Actions, just

  1. fork https://github.com/git-for-windows/msys2-runtime,
  2. apply https://github.com/msys2/msys2-runtime/commit/4606a4f01af766efb0ac9a8814bd9cf70c1d02a1.patch
  3. apply https://raw.githubusercontent.com/TBBle/MSYS2-packages/375689d69776fa54a1262439c26c1e2dffdf8c42/msys2-runtime/0026-Disable-FAST_CWD-when-Wine-is-detected.patch
  4. make sure that you enabled GitHub Actions on your fork
  5. push

After the build is done, there will be an "install.zip" artifact containing the msys-2.0.dll you need to copy into your setup for testing.

@rimrul
Copy link
Member
rimrul commented Oct 20, 2021

I fear that this has been reported e.g. as https://bugs.winehq.org/show_bug.cgi?id=40528, without any resolution I can see there.

That page does talk about a patch in https://bugs.winehq.org/show_bug.cgi?id=48891

And quickly skimming that page, it sounds like the patch has made it into wine 6.11

So updating to a newer version of wine might help.

@rimrul
Copy link
Member
rimrul commented Oct 20, 2021

It looks as if TBBle/MSYS2-packages@375689d has a potential fix, I have no idea where this patch was/is on the way into MSYS2 or Cygwin

I think this comment has a status summary:

msys2/MSYS2-packages#682 (comment)

@mcfreis
Copy link
Author
mcfreis commented Oct 21, 2021

I'm narrowing it down but somehow loosing my target, which was "make a docker image based on Debian Bullseye with Wine, mingw-gcc and Python 3.7." The side effect is, that Python in Wine uses Git with Pip to install modules ...

Ok, what have I done now? First installed Wine 6.19 from winehq-devel, switched to win10 emulation with winetricks and installed "Git for Windows" as follows:
a) Tried Git-2.33.1-64-bit.exe without success ... installation does not finish, abort with ctrl-c.
b) Used MinGit-2.33.1-64-bit.zip, unzipped it, added the paths to the environment and used once the original msys-2.0.dll and the newly built msys-2.0.dll (as described by @dscho ). Both fail:

root@8f318f305d55:~/build# wine git clone ssh://git@gitlab-prod.****:2222/rnd-team/pytools/tchpy3lib.git

0044:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0044:err:winediag:nodrv_CreateWindow Make sure that your X server is running and that $DISPLAY is set correctly.
0044:err:systray:initialize_systray Could not create tray window

Cloning into 'tchpy3lib'...

010c:fixme:ntdll:NtSetInformationToken unimplemented class 4
010c:fixme:virtual:NtAllocateVirtualMemoryEx Ignoring 1 extended parameters 0x21fcd0
010c:fixme:security:GetWindowsAccountDomainSid (00007FFFFFDAC170 000000000024AED8 00007FFFFFDAC16C): semi-stub
010c:fixme:netapi32:DsEnumerateDomainTrustsW ((null), 0x0023, 00007FFFFFDAC348, 00007FFFFFDAC334): stub
0114:fixme:wldap32:ldap_set_optionA Unsupported option: 0x95
0114:fixme:wldap32:ldap_set_optionA Unsupported option: 0x96
010c:fixme:netapi32:NetUserGetInfo Only implemented for local computer, but remote serverL"\\\\@" was requested.
010c:fixme:winsock:addrinfo_flags_to_unix unhandled flags 0x80000
010c:fixme:winsock:addrinfo_flags_to_unix unhandled flags 0x80000

Warning: Permanently added '[gitlab-prod.****]:2222' (ED25519) to the list of known hosts.

010c:err:virtual:virtual_setup_exception stack overflow 976 bytes in thread 010c addr 0x7bc5273c stack 0x7fffffbb0c30 (0x7fffffbb0000-0x7fffffbb1000-0x7fffffdb0000)

^C012c:fixme:console:default_ctrl_handler Terminating process 20 on event 0

root@8f318f305d55:~/build#

What I the tried, is different protocols to clone, and the errors coe in when using ssh+git, so I tried plain ssh without success:
b1) with the original msys-2.0.dll

root@f9e2cc0ede0c:~/build# wine ssh tfb@as-swdevdev-p1

0164:fixme:ntdll:NtSetInformationToken unimplemented class 4
0164:fixme:virtual:NtAllocateVirtualMemoryEx Ignoring 1 extended parameters 0x21fcd0

Cygwin WARNING:
  Couldn't compute FAST_CWD pointer.  This typically occurs if you're using
  an older Cygwin version on a newer Windows.  Please update to the latest
  available Cygwin version from https://cygwin.com/.  If the problem persists,
  please see https://cygwin.com/problems.html

0164:fixme:security:GetWindowsAccountDomainSid (00007FFFFFDAC080 00000000002497E8 00007FFFFFDAC07C): semi-stub
0164:fixme:netapi32:DsEnumerateDomainTrustsW ((null), 0x0023, 00007FFFFFDAC258, 00007FFFFFDAC244): stub
016c:fixme:wldap32:ldap_set_optionA Unsupported option: 0x95
016c:fixme:wldap32:ldap_set_optionA Unsupported option: 0x96
0164:fixme:netapi32:NetUserGetInfo Only implemented for local computer, but remote serverL"\\\\@" was requested.
0164:fixme:winsock:addrinfo_flags_to_unix unhandled flags 0x80000
0164:fixme:winsock:addrinfo_flags_to_unix unhandled flags 0x80000

Warning: Permanently added 'as-swdevdev-p1' (ED25519) to the list of known hosts.

0164:err:virtual:virtual_setup_exception stack overflow 848 bytes in thread 0164 addr 0x7bc5273c stack 0x7fffffbb0cb0 (0x7fffffbb0000-0x7fffffbb1000-0x7fffffdb0000)

^C0178:fixme:console:default_ctrl_handler Terminating process 150 on event 0

root@f9e2cc0ede0c:~/build#

b2) with the patched msys-2.0.dll

root@ea8cdebd5199:~/build# wine ssh tfb@as-swdevdev-p1
0044:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0044:err:winediag:nodrv_CreateWindow Make sure that your X server is running and that $DISPLAY is set correctly.
0044:err:systray:initialize_systray Could not create tray window
Application could not be started, or no application associated with the specified file.
ShellExecuteEx failed: File not found.

root@ea8cdebd5199:~/build#

I'm quite lost .... I believe the error lies in ssh included in "Git for Windows". But the patched msys-2.0.dll didn't help :-(

@rimrul
Copy link
Member
rimrul commented Oct 21, 2021

I'm not quite sure on the details how pip and python modules work, but assuming they're pure python, could you side-step the whole issue by using debian pip and debian git to download the dependencies for windows python?

@mcfreis
Copy link
Author
mcfreis commented Oct 21, 2021

@rimrul This could be possible on pure python modules, but not on win32 specific modules. Mixing it would be a mess.

I managed to get a password prompt for wine ssh user@host after changing Wine emulation to vista but the password input is echoed back and nothing else happens :-( If I supply the password in the URL, the clone works. Somehow the stdin from ssh receives nothing ...

@mcfreis
Copy link
Author
mcfreis commented Oct 22, 2021

Further investigation conclued to me, that it has to do with ssh. If I want to do an ssh connection where I'm asked any question, I cannot give input to the ssh client. I believe in the ssh client in usage with wine, there is some sort of error.

@rimrul
Copy link
Member
rimrul commented Oct 22, 2021

You might be able to specify a custom askpass using the SSH_ASKPASS environment variable.

@rimrul
Copy link
Member
rimrul commented Oct 22, 2021

Alternatively you might have success with Mircrosofts OpenSSH instead of ours.

@dscho
Copy link
Member
dscho commented Oct 22, 2021

You might be able to specify a custom askpass using the SSH_ASKPASS environment variable.

It is probably set to /mingw64/bin/git-askpass.exe, which is a GUI-only program. Use unset SSH_ASKPASS to clear that setting.

(This is set in /etc/profile.d/env.sh, if you want to build a Docker image, it would probably make sense to either edit that file, or to add a ~/.bash_profile that unsets it.)

@mcfreis
Copy link
Author
mcfreis commented Oct 22, 2021

Alternatively you might have success with Mircrosofts OpenSSH instead of ours.

How would I do this? Install it in wine and then where to configure the usage within Git_for_Windows?

@dscho
Copy link
Member
dscho commented Oct 22, 2021

Alternatively you might have success with Mircrosofts OpenSSH instead of ours.

How would I do this? Install it in wine and then where to configure the usage within Git_for_Windows?

You would download a .zip from https://github.com/PowerShell/Win32-OpenSSH/releases/, extract it, and set core.sshCommand to point to the ssh.exe.

@mcfreis
Copy link
Author
mcfreis commented Oct 22, 2021

Managed to make it work with OpenSSH-Win64 and the gitconfig core.sshCommand pointing to OpenSSH-Win64 -> git clone with ssh works in wine :-)

Somehow I can't call wine $WINEPREFIX/drive_c/git/bin/git.exe config --system --add core.sshCommand "C:/OpenSSH-Win64/ssh.exe" - it crashes with the same error picture as in post 1 - but that is another story.

Thanks all :-)

@mcfreis
Copy link
Author
mcfreis commented Oct 22, 2021

The Problem now remains in the step docker build -f Dockerfile . with the message:

 > [33/33] RUN true     && GIT_TRACE=true wine /root/.wine64/drive_c/git/bin/git.exe config --system --add core.sshCommand "C:/OpenSSH-Win64/ssh.exe":
#37 1.287 wine: Unhandled page fault on write access to 0000000000000000 at address 00000001402616EB (thread 00fc), starting debugger...
#37 1.454 Unhandled exception: page fault on write access to 0x00000000 in 64-bit code (0x00000001402616eb).
#37 1.474 Register dump:
#37 1.474  rip:00000000402616eb rsp:000000000021f780 rbp:0000000000000049 eflags:00010246 (  R- --  I  Z- -P- )
#37 1.474  rax:0000000000000000 rbx:0000000000000000 rcx:0000000000000000 rdx:0000000000000000
#37 1.474  rsi:00000000a77ec020 rdi:00000000a77ec020  r8:000000000023f850  r9:00000000000003fe r10:0000000000000008
#37 1.474  r11:0000000000000246 r12:0000000000000000 r13:0000000000ad06e8 r14:0000000000000007 r15:0000000000ad0628
#37 1.474 Stack dump:
#37 1.474 0x000000000021f780:  000000006a0ec1d0 0000000067fe0000
#37 1.474 0x000000000021f790:  0000000000ad0498 000000006a0f0d10
#37 1.475 0x000000000021f7a0:  000000000021f7bc 0000000000000000
#37 1.475 0x000000000021f7b0:  0000000000000000 000000007bc56b95
#37 1.476 0x000000000021f7c0:  0000000000000000 0000000000000000
#37 1.476 0x000000000021f7d0:  0000000000000000 0000000000000000
#37 1.476 0x000000000021f7e0:  0000000000000000 0000000040292b7d
#37 1.477 0x000000000021f7f0:  000000000021f7d0 000000006a0f0c26
#37 1.477 0x000000000021f800:  00000000402945b0 0000000000245450
#37 1.477 0x000000000021f810:  0000000000ad0498 0000000040001540
#37 1.478 0x000000000021f820:  0000000000000038 000000006a097168
#37 1.478 0x000000000021f830:  0000000000000000 000000000000000b
#37 1.478 Backtrace:
#37 1.478 =>0 0x00000001402616eb in git (+0x2616eb) (0x0000000000000049)
#37 1.478   1 0x0000000140262527 in git (+0x262526) (0x0000000000000049)
#37 1.478   2 0x000000014026045a in git (+0x260459) (0x0000000000000049)
#37 1.478   3 0x00000001400013d4 in git (+0x13d3) (0x0000000000ad0498)
#37 1.478   4 0x0000000140001506 in git (+0x1505) (0x0000000000000000)
#37 1.502   5 0x000000007b62c659 BaseThreadInitThunk+0x8(unknown=<is not available>, entry=<is not available>, arg=<is not available>) [Z:\usr\src\packages\BUILD\dlls\kernel32\thread.c:61] in kernel32 (0x0000000000000000)
#37 1.550   6 0x000000007bc56fa3 RtlUserThreadStart+0x82(entry=00000001400014F0, arg=0000000067FF0000) [Z:\usr\src\packages\BUILD\dlls\ntdll\thread.c:241] in ntdll (0x0000000000000000)
#37 1.551 0x00000001402616eb: movw      %dx,(%r12,%rax,2)
#37 1.551 Modules:
#37 1.551 Module        Address                                 Debug info      Name (21 modules)
#37 1.551 PE            61540000-        6162f000       Deferred        advapi32
#37 1.551 PE            62dc0000-        62fc4000       Deferred        rpcrt4
#37 1.551 PE            63280000-        6329b000       Deferred        version
#37 1.551 PE            66900000-        66959000       Deferred        win32u
#37 1.551 PE            6a080000-        6a2e5000       Deferred        msvcrt
#37 1.551 PE            6ba00000-        6ba94000       Deferred        sechost
#37 1.551 PE            6bac0000-        6bc3e000       Deferred        setupapi
#37 1.551 PE            6c7c0000-        6c9b9000       Deferred        gdi32
#37 1.551 PE            6d580000-        6d5fb000       Deferred        ws2_32
#37 1.551 PE            6eb00000-        6f18b000       Deferred        user32
#37 1.551 PE            70940000-        70c03000       Deferred        ucrtbase
#37 1.551 PE            71000000-        7104d000       Deferred        imm32
#37 1.551 PE            7b000000-        7b30c000       Deferred        kernelbase
#37 1.551 PE            7b600000-        7b91a000       Dwarf-2         kernel32
#37 1.551 PE            7bc00000-        7be65000       Dwarf-2         ntdll
#37 1.551 PE           140000000-       140388000       Export          git
#37 1.551 PE           214d20000-       214e2b000       Deferred        libiconv-2
#37 1.551 PE           2209f0000-       220a18000       Deferred        libintl-8
#37 1.551 PE           2330a0000-       23313e000       Deferred        libpcre2-8-0
#37 1.551 PE           241b90000-       241bb4000       Deferred        zlib1
#37 1.551 PE           2a77e0000-       2a77f2000       Deferred        libssp-0
#37 1.552 Threads:
#37 1.555 process  tid      prio (all id:s are in hex)
#37 1.556 00000020 start.exe
#37 1.556       00000024    0
#37 1.558 00000030 winemenubuilder.exe
#37 1.558       00000034    0
#37 1.561 00000038 services.exe
#37 1.561       0000003c    0
#37 1.561       00000048    0
#37 1.562       00000054    0
#37 1.562       00000058    0
#37 1.562       00000078    0
#37 1.563       0000007c    0
#37 1.563       00000088    0
#37 1.563       000000a4    0
#37 1.564       000000bc    0
#37 1.564       000000d4    0
#37 1.567 00000040 explorer.exe
#37 1.567       00000044    0
#37 1.567       00000070    0
#37 1.570 0000004c winedevice.exe
#37 1.570       00000050    0
#37 1.570       0000005c    0
#37 1.571       00000060    0
#37 1.571       000000c8    0
#37 1.574 00000068 winedevice.exe
#37 1.574       0000006c    0
#37 1.575       00000080    0
#37 1.575       00000084    0
#37 1.575       0000008c    0
#37 1.576       00000090    0
#37 1.576       00000094    0
#37 1.577       00000098    0
#37 1.580 0000009c plugplay.exe
#37 1.580       000000a0    0
#37 1.580       000000a8    0
#37 1.580       000000ac    0
#37 1.581       000000b0    0
#37 1.584 000000b4 svchost.exe
#37 1.584       000000b8    0
#37 1.584       000000c0    0
#37 1.584       000000c4    0
#37 1.587 000000cc rpcss.exe
#37 1.587       000000d0    0
#37 1.587       000000d8    0
#37 1.587       000000dc    0
#37 1.588       000000e0    0
#37 1.588       000000e4    0
#37 1.588       000000e8    0
#37 1.588       000000ec    0
#37 1.592 000000f0 git.exe
#37 1.592       000000f4    0
#37 1.592 000000f8 (D) C:\git\mingw64\bin\git.exe
#37 1.592       000000fc    0 <==
#37 1.592       00000108    0
#37 1.593 System information:
#37 1.593     Wine build: wine-6.19
#37 1.593     Platform: x86_64
#37 1.593     Version: Windows Vista
#37 1.593     Host system: Linux
#37 1.593     Host version: 5.10.16.3-microsoft-standard-WSL2
------
executor failed running [/bin/sh -c true        && GIT_TRACE=true wine $WINEPREFIX/drive_c/git/bin/git.exe config --system --add core.sshCommand "C:/OpenSSH-Win64/ssh.exe"]: exit code: 5

GIT_TRACE=true didn't show anything useful. Any ideas how to dig into this?

@dscho
Copy link
Member
dscho commented Oct 22, 2021

Does it work if you use --global instead of --system?

@mcfreis
Copy link
Author
mcfreis commented Oct 22, 2021

Does it work if you use --global instead of --system?

It doesn't matter if I call wine git or wine git clone or wine git --version or wine git config --global, all show the same dump.

Maybe the build environment from docker is missing something, that the later run environment has? Some variables or settings?

@dscho
Copy link
Member
dscho commented Oct 23, 2021

Hmm. The stack trace suggests a NULL pointer access, which is bad.

Maybe call cmd/git.exe instead of mingw64/bin/git.exe?

And maybe setting GIT_TRACE2_EVENT to a file path, and then inspecting the last few lines, shines more light on this bug?

Also, is there any easy way for others to reproduce this?

@mcfreis
Copy link
Author
mcfreis commented Oct 25, 2021

@dscho If cmd/git.exe or the other one makes no difference.

To reproduce this, I created a repo Wine64-with-Git_for_Windows which builds the docker image, but fails in the last step because of the Null pointer access.

May that help?

@dscho
Copy link
Member
dscho commented Oct 25, 2021

Seems that I am currently unable to run Docker in my WSL2 instance. So I gave plain wine a try in my Ubuntu 18.04, and it says this:

$ wine /mnt/c/git-sdk-64/cmd/git.exe version
it looks like wine32 is missing, you should install it.
multiarch needs to be enabled first.  as root, please
execute "dpkg --add-architecture i386 && apt-get update &&
apt-get install wine32"
001e:err:module:attach_dlls "libiconv-2.dll" failed to initialize, aborting
001e:err:module:attach_dlls Initializing dlls for L"Z:\\mnt\\c\\git-sdk-64\\mingw64\\bin\\git.exe" failed, status c0000005

Not sure whether you can reproduce this in a minimal Docker configuration?

@dscho
Copy link
Member
dscho commented Oct 25, 2021

And after installing win32 as suggested, I get this, of course:

$ wine /mnt/c/git-sdk-64/cmd/git.exe version
0020:err:module:attach_dlls "libiconv-2.dll" failed to initialize, aborting
0020:err:module:attach_dlls Initializing dlls for L"Z:\\mnt\\c\\git-sdk-64\\mingw64\\bin\\git.exe" failed, status c0000005

@mcfreis
Copy link
Author
mcfreis commented Oct 25, 2021

@dscho I think we need the docker subsystem for the error to be reproduced. Can you run docker build within a Linux distro? I'll try to night.

@dscho
Copy link
Member
dscho commented Oct 26, 2021

Can you run docker build within a Linux distro?

Nope. I do have a WSL2 instance to test things with, but look here:

$ docker build --progress=plain -t wine64-with-git_for_windows:1.0.0 -f Dockerfile .
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

and:

$ sudo service docker start
docker: unrecognized service

Apparently you have to install Windows Docker Desktop and jump through a couple of hoops, which I am not really willing to invest the time for, given that we are talking about a pretty fringe scenario ;-)

@mcfreis
Copy link
Author
mcfreis commented Nov 1, 2021

@dscho I tried a few things last weekend although I couldn't reproduce your libiconv-2.dll error.

  1. Native Ubuntu LTS with Winehq-Devel and Git_for_windows (+ patched msys-2.0.dll) and the OpenSSH-win64 works fine.

  2. With the docker build within the Native Ubuntu LTS, I receive the same crash as in post.

I believe it's an issue with the docker build environment vs. run environment.

Thanks for all your help, I apreciate your effort. Thx.

If I come up with a solution, I'll append it - but for now it has to suffice as it is.

@dscho
Copy link
Member
dscho commented Nov 1, 2021

I hope you can get to the bottom of this. Let's leave the ticket open for now.

@mcfreis
Copy link
Author
mcfreis commented Nov 10, 2021

I added Github Actions to build the docker image with the same results as if run locally.

https://github.com/mcfreis/Wine64-with-Git_for_Windows/runs/4165186134?check_suite_focus=true

Maybe this helps for further analysis?

@dscho
Copy link
Member
dscho commented Nov 10, 2021

Maybe this helps for further analysis?

Absolutely, it will make it possible to use tmate to debug this, directly on the build agent.

But not right now. Right now, we're in the middle of the -rc phase, Git v2.34.0 is scheduled to appear this coming Monday.

@dscho dscho added this to the After next release milestone Nov 11, 2021
@dscho dscho modified the milestones: v2.34.1, Next release Nov 24, 2021
@dscho dscho modified the milestones: v2.35.0, Next release Jan 15, 2022
@dscho
Copy link
Member
dscho commented Mar 10, 2022

Oy, I fear I don't really have the resources to take care of this. @mcfreis could I talk you through building Git for Windows and/or OpenSSH and/or the MSYS2 runtime, adding tons of debug messages, and then investigating further? It is really frustrating and I am sorry that I won't be able to help more meaningfully.

@dscho dscho removed this from the Next release milestone Mar 22, 2022
@1480c1
Copy link
1480c1 commented May 28, 2022

Hi, I'm running into a similar issue with git, but in my case, the command I'm running is

echo "$(wine64 /cmd/git.exe --version 2>/dev/null)"

and it outputs with a similar "coredump" as #3478 (comment)

My situation is similar in that it's inside docker, but mine is using archlinux as the base and is using pacman to install msys2's packages, and then the packages from the "https://wingit.blob.core.windows.net/x86-64" repo on top of them.

I tried using the packages provided in https://dev.azure.com/Git-for-Windows/git/_build/results?buildId=99619&view=artifacts&pathAsName=false&type=publishedArtifacts under pkg-x86_64 to get a non-stripped version of git.exe and got this as my "coredump" output

coredump
  $ echo "$(wine64 /cmd/git.exe --version 2>/dev/null)"
Unhandled exception: page fault on write access to 0x0000000000000000 in 64-bit code (0x0000014027aa7b).
Register dump:
 rip:000000014027aa7b rsp:000000000021f780 rbp:000000000000001c eflags:00010246 (  R- --  I  Z- -P- )
 rax:0000000000000000 rbx:0000000000000001 rcx:0000000000000000 rdx:0000000000000000
 rsi:00000002a77ec020 rdi:00000002a77ec020  r8:000000007ebba590  r9:00000000000003fe r10:0000000000000008
 r11:0000000000000246 r12:0000000000000000 r13:0000000000d60558 r14:0000000000000003 r15:0000000000d60528
Stack dump:
0x0000000021f780:  00000001c8e21b50 0000000140001540
0x0000000021f790:  0000000000000018 00000001c8e1d1d0
0x0000000021f7a0:  000000000021f7bc 000000017005ce47
0x0000000021f7b0:  00000000003318b0 000000107005b7fe
0x0000000021f7c0:  0000000000000000 0000000000000000
0x0000000021f7d0:  0000000000000000 0000000000000000
0x0000000021f7e0:  00000001c8e21a66 00000001402a3b90
0x0000000021f7f0:  0000000000335a90 0000000000d60498
0x0000000021f800:  0000000140001540 0000000000000018
0x0000000021f810:  00000001c8e1d1d0 00000001c8dc7328
0x0000000021f820:  0000000000000000 0000000000000000
0x0000000021f830:  000000000021f810 0000000000334e50
Backtrace:
=>0 0x0000014027aa7b detect_msys_tty+0x9b() in git (0x0000000000001c)
  1 0x0000014027b921 winansi_init+0x241() in git (0x0000000000001c)
  2 0x000001402797ea wmain+0x27a() in git (0x0000000000001c)
  3 0x000001400013d4 __tmainCRTStartup+0x254() in git (0x00000000d60498)
  4 0x00000140001506 mainCRTStartup+0x16() in git (0000000000000000)
  5 0x0000007b62bc39 ActivateActCtx+0x20081() in kernel32 (0000000000000000)
  6 0x0000017005d263 A_SHAFinal+0x3a6a3() in ntdll (0000000000000000)
0x0000014027aa7b detect_msys_tty+0x9b in git: movw      %dx,(%r12,%rax,2)
Modules:
Module  Address                                 Debug info      Name (44 modules)
PE      000000007b000000-000000007b24d000       Deferred        kernelbase
PE      000000007b600000-000000007b65e000       Export          kernel32
ELF     000000007d000000-000000007d005000       Deferred        <wine-loader>
PE      0000000140000000-000000014039d000       PDB             git
PE      0000000170000000-00000001700a0000       Export          ntdll
PE      00000001c8db0000-00000001c8e47000       Deferred        msvcrt
PE      00000001ec2b0000-00000001ec2d6000       Deferred        ws2_32
PE      0000000214d20000-0000000214e2b000       Deferred        libiconv-2
PE      00000002209f0000-0000000220a18000       Deferred        libintl-8
PE      00000002330a0000-0000000233143000       Deferred        libpcre2-8-0
PE      000000023d820000-000000023d9ee000       Deferred        user32
PE      0000000241b90000-0000000241bb4000       Deferred        zlib1
PE      000000026b4c0000-000000026b53b000       Deferred        gdi32
PE      00000002a77e0000-00000002a77f2000       Deferred        libssp-0
PE      00000002f1fa0000-00000002f1fad000       Deferred        version
PE      000000032a700000-000000032a729000       Deferred        sechost
PE      0000000330260000-000000033029f000       Deferred        advapi32
PE      0000000375610000-0000000375649000       Deferred        win32u
PE      00000003af670000-00000003af730000       Deferred        ucrtbase
PE      00000003afd00000-00000003afd1a000       Deferred        imm32
ELF     00007f4aa3fc3000-00007f4aa3ff4000       Deferred        libexpat.so.1
ELF     00007f4aa3ff4000-00007f4aa4044000       Deferred        libfontconfig.so.1
ELF     00007f4aa4044000-00007f4aa40bb000       Deferred        libpcre.so.1
ELF     00007f4aa40bb000-00007f4aa41f9000       Deferred        libglib-2.0.so.0
ELF     00007f4aa41f9000-00007f4aa421b000       Deferred        libgraphite2.so.3
ELF     00007f4aa421b000-00007f4aa4304000       Deferred        libharfbuzz.so.0
ELF     00007f4aa4304000-00007f4aa433b000       Deferred        libpng16.so.16
ELF     00007f4aa433b000-00007f4aa434e000       Deferred        libbz2.so.1.0
ELF     00007f4aa434e000-00007f4aa441d000       Deferred        libfreetype.so.6
ELF     00007f4aa441d000-00007f4aa4440000       Deferred        libbrotlicommon.so.1
ELF     00007f4aa4440000-00007f4aa4445000       Deferred        libpthread.so.0
ELF     00007f4aa4445000-00007f4aa444a000       Deferred        libdl.so.2
ELF     00007f4aa444a000-00007f4aa4456000       Deferred        libffi.so.8
ELF     00007f4aa481c000-00007f4aa482a000       Deferred        libbrotlidec.so.1
ELF     00007f4aa48cf000-00007f4aa4a02000       Deferred        libp11-kit.so.0
ELF     00007f4aa4a02000-00007f4aa4a1c000       Deferred        libz.so.1
ELF     00007f4aa4c35000-00007f4aa4d1c000       Deferred        libm.so.6
ELF     00007f4aa4d1c000-00007f4aa4ea7000       Deferred        win32u.so
ELF     00007f4aa51a7000-00007f4aa531e000       Dwarf           libwine.so.1
ELF     00007f4aa5707000-00007f4aa5731000       Deferred        liblzma.so.5
ELF     00007f4aa5731000-00007f4aa574b000       Deferred        libunwind.so.8
ELF     00007f4aa574b000-00007f4aa580b000       Deferred        ntdll.so
ELF     00007f4aa5a29000-00007f4aa5a2f000       Deferred        ws2_32.so
ELF     00007f4aa5a2f000-00007f4aa5a68000       Deferred        ld-linux-x86-64.so.2
Threads:
process  tid      prio    name (all IDs are in hex)
00000020 start.exe
        ["C:\windows\system32\start.exe" /exec /cmd/git.exe --version]
        00000024    0     
00000038 services.exe
        ["C:\windows\system32\services.exe"]
        0000003c    0     
        00000040    0     
        00000054    0     
        00000058    0     
        00000074    0     
        0000008c    0     
        000000a4    0     
        000000bc    0     
        000000d4    0     
00000044 winedevice.exe
        [C:\windows\system32\winedevice.exe]
        00000048    0     
        0000005c    0     
        00000060    0     
        00000064    0     
        000000c8    0     
0000004c explorer.exe
        ["C:\windows\system32\explorer.exe" /desktop]
        00000050    0     
        00000084    0     
0000006c winedevice.exe
        [C:\windows\system32\winedevice.exe]
        00000070    0     
        00000078    0     
        0000007c    0     
        00000080    0     
        00000090    0     
        00000094    0     
        00000098    0     
0000009c plugplay.exe
        [C:\windows\system32\plugplay.exe]
        000000a0    0     
        000000a8    0     
        000000ac    0     
        000000b0    0     
000000b4 svchost.exe
        [C:\windows\system32\svchost.exe -k LocalServiceNetworkRestricted]
        000000b8    0     
        000000c0    0     
        000000c4    0     
000000cc rpcss.exe
        [C:\windows\system32\rpcss.exe]
        000000d0    0     
        000000d8    0     
        000000dc    0     
        000000e0    0     
        000000e4    0     
        000000e8    0     
        000000ec    0     
        00000120    0     
000000f0 conhost.exe
        ["C:\windows\system32\conhost.exe" --unix --width 0 --height 0 --server 0x34]
        000000f4    0     
000000f8 git.exe
        ["Z:\cmd\git.exe" --version]
        000000fc    0     
00000100 (D) Z:\mingw64\bin\git.exe
        [git.exe --version]
        00000104    0 <== 
        00000110    0     
00000114 explorer.exe
        ["C:\windows\system32\explorer.exe" /desktop]
        00000118    0     
        0000011c    0     
System information:
    Wine build: wine-7.7 (Staging)
    Platform: x86_64
    Version: Windows 7
    Host system: Linux
    Host version: 5.18.0-1-MANJARO

I will try to see if I can follow the guide at https://github.com/git-for-windows/git/wiki/Building-Git to build a full debug version to see if I could potentially get the exact line it's failing at, but I am not sure how to really debug with wine, especially when trying to debug a command that only crashes under specific circumstances (only stderr redirected to anything (stdout redirected doesn't trigger this) and this only occurs when I run it inside a subshell)

@1480c1
Copy link
1480c1 commented May 28, 2022

Since I was a bit impatient, I decided to try to dissect detect_msys_tty() on its own using classic printf debugging, and lo and behold,

#include <stdio.h>
#include <io.h>
#include <windows.h>
#include <winternl.h>
#include <ntstatus.h>

static int fd_is_interactive[3] = {0, 0, 0};
#define FD_CONSOLE 0x1
#define FD_SWAPPED 0x2
#define FD_MSYS 0x4

static void detect_msys_tty(int fd) {
    ULONG                    result;
    BYTE                     buffer[1024];
    POBJECT_NAME_INFORMATION nameinfo = (POBJECT_NAME_INFORMATION)buffer;
    PWSTR                    name;

    printf("detect_msys_tty(%d)\n", fd);
    /* check if fd is a pipe */
    HANDLE h = (HANDLE)_get_osfhandle(fd);
    printf("got here 1\n");
    if (GetFileType(h) != FILE_TYPE_PIPE)
        return;

    printf("got here 2\n");
    /* get pipe name */
    if (!NT_SUCCESS(NtQueryObject(h, ObjectNameInformation, buffer, sizeof(buffer) - 2, &result)))
        return;

    printf("got here 3: %p %u\n", nameinfo->Name.Buffer, nameinfo->Name.Length);
    name                                        = nameinfo->Name.Buffer;
    name[nameinfo->Name.Length / sizeof(*name)] = 0;

    /*
	 * Check if this could be a MSYS2 pty pipe ('msys-XXXX-ptyN-XX')
	 * or a cygwin pty pipe ('cygwin-XXXX-ptyN-XX')
	 */
    if ((!wcsstr(name, L"msys-") && !wcsstr(name, L"cygwin-")) || !wcsstr(name, L"-pty"))
        return;

    printf("got here 4\n");

    if (fd == 2) {
        printf("got here 5\n");
        setvbuf(stderr, NULL, _IONBF, BUFSIZ);
    }

    printf("got here 6\n");
    fd_is_interactive[fd] |= FD_MSYS;
}

int main() {
    detect_msys_tty(0);
    detect_msys_tty(1);
    detect_msys_tty(2);
}
echo "$(./a.exe 2>/dev/null)"
detect_msys_tty(0)
got here 1
detect_msys_tty(1)
got here 1
got here 2
got here 3: 0000000000000000 0
Unhandled exception: page fault on write access to 0x0000000000000000 in 64-bit code (0x000001400016a0).
Register dump:
 rip:00000001400016a0 rsp:000000000021f8c0 rbp:000000000021f940 eflags:00010246 (  R- --  I  Z- -P- )

the issue seems to be that wine isn't properly filling out the Name.Buffer and Name.Length field inside NtQueryObject(), or git isn't checking that properly or is using the function properly, which does strike me weird looking at https://docs.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntqueryobject and not seeing ObjectNameInformation anywhere, but it does seem to be documented elsewhere, just not on their docs.

I think the smallest fix would be

diff --git a/compat/winansi.c b/compat/winansi.c
index 3abe8dd5a2..855897e6dd 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -573,6 +573,8 @@ static void detect_msys_tty(int fd)
        if (!NT_SUCCESS(NtQueryObject(h, ObjectNameInformation,
                        buffer, sizeof(buffer) - 2, &result)))
                return;
+       if (result <= sizeof(*nameinfo))
+               return;
        name = nameinfo->Name.Buffer;
        name[nameinfo->Name.Length / sizeof(*name)] = 0;
 

based on looking at wine's code since it sets result to 16 in the case of no name

@dscho would that be an acceptable bandaid for now? Or could there be a better option?

@dscho
Copy link
Member
dscho commented May 30, 2022

I will try to see if I can follow the guide at https://github.com/git-for-windows/git/wiki/Building-Git

Thank you for reverting the phishing attempt on the wiki!

@dscho would that be an acceptable bandaid for now? Or could there be a better option?

Awesome analysis, and thank you for being so responsive in #3875! I've since merged it and the latest snapshot has the fix. Could I ask you to verify the fix?

@1480c1
Copy link
1480c1 commented May 30, 2022

Awesome analysis, and thank you for being so responsive in #3875! I've since merged it and the latest snapshot has the fix. Could I ask you to verify the fix?

I've pulled the pacman suitable packages from https://dev.azure.com/Git-for-Windows/git/_build/results?buildId=100237&view=artifacts&pathAsName=false&type=publishedArtifacts since it has the same commit hash as the latest snapshot.

Using the /cmd/git.exe and co from that package, I can confirm that both the use case of git clone from inside the dockerfile as

RUN git.exe clone https://gitlab.com/AOMediaCodec/SVT-AV1.git && \
    cmake.exe -B bui -S SVT-AV1/ -GNinja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF && \
    ninja.exe -C bui

and the echo command of

[root@db8cdc4507b9 /]# echo $(wine64 git.exe --version 2>/dev/null)
git version 2.36.1.windows.1.14.gc5ca16f7d9.20220530182759

works with no issue

@1480c1
Copy link
1480c1 commented May 30, 2022

Right now, I'm facing a bit of a different issue with

[root@db8cdc4507b9 SVT-AV1]# git clone $PWD temp
Cloning into 'temp'...
Skipping command-line '"Z:\usr\bin\..\usr\bin\bash.exe"'
('Z:\usr\bin\..\usr\bin\bash.exe' not found)
Need a valid command-line; Edit the string resources accordingly
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

but that seems to be a bash.exe issue

[root@db8cdc4507b9 SVT-AV1]# bash.exe -l
Skipping command-line '"Z:\usr\bin\..\usr\bin\bash.exe"'
('Z:\usr\bin\..\usr\bin\bash.exe' not found)
Need a valid command-line; Edit the string resources accordingly

so it is unrelated to this issue, and I presume git-for-windows

@dscho
Copy link
Member
dscho commented May 31, 2022
[root@db8cdc4507b9 SVT-AV1]# bash.exe -l
Skipping command-line '"Z:\usr\bin\..\usr\bin\bash.exe"'
('Z:\usr\bin\..\usr\bin\bash.exe' not found)
Need a valid command-line; Edit the string resources accordingly

Which bash.exe does this try to find?

@1480c1
Copy link
1480c1 commented May 31, 2022

I can only presume it was trying to find /usr/bin/bash.exe from git-for-windows/bash, but somehow managed to fumble the string into looking for /usr/usr/bin/bash.exe, I'm not yet sure where the issue stems from just yet

@dscho
Copy link
Member
dscho commented Jun 1, 2022

Well, if your Z:\usr\bin\bash.exe happens to be a copy of the Git wrapper by mistake, that would explain the funny command-line.

@1480c1
Copy link
1480c1 commented Jun 1, 2022

Considering that inside the arch container, /bin is a symlink to /usr/bin, that seems very possible. I will try to see what happens if I unsymlink the two and then install bash from git-for-windows.

@1480c1
Copy link
1480c1 commented Jun 1, 2022

Seems a lot of things in arch rely on /bin/<command> existing, seems there's a lot of sedding in my future

@1480c1
Copy link
1480c1 commented Jun 1, 2022

image
seems like busybox is also taking over a few commands

@1480c1
Copy link
1480c1 commented Jun 1, 2022
[root@d107ecdaa845 /]# command -v bash.exe
/usr/sbin/bash.exe
[root@d107ecdaa845 /]# bash.exe -c 'echo 1'
Cygwin WARNING:
  Couldn't compute FAST_CWD pointer.  This typically occurs if you're using
  an older Cygwin version on a newer Windows.  Please update to the latest
  available Cygwin version from https://cygwin.com/.  If the problem persists,
  please see https://cygwin.com/problems.html

1
[root@d107ecdaa845 /]# git.exe clone https://gitlab.com/AOMediaCodec/SVT-AV1.git
Cloning into 'SVT-AV1'...
remote: Enumerating objects: 41498, done.
remote: Counting objects: 100% (3125/3125), done.
remote: Compressing objects: 100% (780/780), done.
remote: Total 41498 (delta 2364), reused 3074 (delta 2323), pack-reused 38373
Receiving objects: 100% (41498/41498), 56.30 MiB | 39.17 MiB/s, done.
Resolving deltas: 100% (32262/32262), done.
[root@d107ecdaa845 /]# cd SVT-AV1/
[root@d107ecdaa845 SVT-AV1]# git clone $PWD svtav1-src
Cloning into 'svtav1-src'...
Cygwin WARNING:
  Couldn't compute FAST_CWD pointer.  This typically occurs if you're using
  an older Cygwin version on a newer Windows.  Please update to the latest
  available Cygwin version from https://cygwin.com/.  If the problem persists,
  please see https://cygwin.com/problems.html

done.
[root@d107ecdaa845 SVT-AV1]# ls svtav1-src/
Build  CHANGELOG.md  CMakeLists.txt  Config  CONTRIBUTING.md  Dockerfile  Docs  ffmpeg_plugin  gstreamer-plugin  LICENSE-BSD2.md  LICENSE.md  PATENTS.md  README.md  snap  Source  STYLE.md  test  third_party

Okay, that got it to work, thanks!

Going to run a ffmpeg build with a few external libraries to see if I encounter any more unique issues with git.exe

@1480c1
Copy link
1480c1 commented Jun 1, 2022

Well, I found an issue, I'm not sure if it's necessarily git-for-windows's fault, but I'm just going to open a new issue instead of tagging on this one since I think the base issue was fixed

@dscho
Copy link
Member
dscho commented Jun 20, 2022

This here ticket was mentioned in https://www.msys2.org/docs/faq/#how-can-i-get-msys2-running-under-wine

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

No branches or pull requests

4 participants