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

MinTTY crashes frequently with a Git Bash using Windows-native pseudo consoles #2687

Closed
1 task done
gdh1995 opened this issue Jun 15, 2020 · 7 comments
Closed
1 task done
Milestone

Comments

@gdh1995
Copy link

gdh1995 commented Jun 15, 2020

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.27.0.windows.1
cpu: x86_64
built from commit: 907ab1011dce9112700498e034b974ba60f8b407
sizeof-long: 4
sizeof-size_t: 8
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [版本 10.0.18363.900]
  • What options did you set as part of the installation? Or did you choose the
    defaults?

No, I unzipped the portable version:

  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

No

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

CMD (enter CMD and call usr\bin\bash.exe directly)

R:\working\git-27$ set PATH=C:\Windows\System32

R:\working\git-27$ .\usr\bin\bash.exe
'C:\WINDOWS\system32\drivers\etc\hosts' -> '/etc/hosts'
'C:\WINDOWS\system32\drivers\etc\protocol' -> '/etc/protocols'
'C:\WINDOWS\system32\drivers\etc\services' -> '/etc/services'
'C:\WINDOWS\system32\drivers\etc\networks' -> '/etc/networks'
bash: git: command not found

# then bash will hung in scripts of /etc/profile,
# but one or two Ctrl+C will interrupt the progress
# and enter a shell (note of gdh1995)

gdh1995@gdh-MiPro MSYS /ls -l ./mintty.exe.stackdump
ls: cannot access './mintty.exe.stackdump': No such file or directory

gdh1995@gdh-MiPro MSYS //usr/bin/mintty.exe -

# mintty should crash very often
# while if it succeeds in opening a window, just press Ctrl-C to interrupt /etc/profile,
# close the MinTTY window and try `/usr/bin/mintty.exe` again and again

gdh1995@gdh-MiPro MSYS /ls -l ./mintty.exe.stackdump
-rw-r--r-- 1 gdh1995 197610 1374  6月 15 22:23 ./mintty.exe.stackdump
  • What did you expect to occur after running these commands?

MinTTY should start successfully - create a window and show a bash prompt. If I don't rewrite /etc/bash.bashrc, then it can enter bash prompt; if /etc/bash.bashrc is replaced as mentioned above, the bash will be stuck into /etc/profile, and then Ctrl-C can interrupt it and make it show bash prompt and accept user input as expected.

  • What actually happened instead?

On v2.27.0, MinTTY crashes very very often, though sometimes it will succeed in opening a new window in several times.

  • According to what I've experienced, if at a time it succeeded, then it would succeed in several following tries, until a next try failed again (a few seconds later)
  • both /usr/bin/mintty.exe and /usr/bin/mintty.exe - will crash

While on v2.26.0 MinTTY always succeeds.

What I've found

I downloaded Git SDK as said in #949 (comment) , compiled mintty using makepkg -s, and modified \usr\src\MSYS2-packages\mintty\src\mintty-3.1.8\src\winmain.c to do tests. Then I find:

  • mintty checks whether it starts from a console
  • if yes, then it wants to detach from parent process
  • so it calls fork and the forked child process will call setsid
  • but setsid(); crashes frequently

image

Stack Dump

The mintty.exe.stackdump from mintty in Git for Windows v2.27.0.windows.1 is:

Exception: STATUS_ACCESS_VIOLATION at rip=00180070B8B
rax=00000000000005A4 rbx=0000000180211F30 rcx=0000000180347CA0
rdx=0000000000000000 rsi=00000001802188E0 rdi=8000000080000000
r8 =00000000FFFFC498 r9 =00000000FFFFC670 r10=0000000000000000
r11=0000000000000246 r12=0000000180347CA0 r13=000000018022B8AC
r14=0000000000000002 r15=00000001004C8780
rbp=00000000FFFFC670 rsp=00000000FFFFC440
program=D:\Git\usr\bin\mintty.exe, pid 1242, thread main
cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace:
Frame        Function    Args
000FFFFC670  00180070B8B (000000002D4, 000FFFFE460, 00000000000, 00000000000)
000FFFFC670  001800759D3 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFC670  0018006E041 (000FFFFC000, 00100000000, 00000003000, 001004B345C)
000FFFFC670  00180045CC0 (00000000001, 000FFFFC63F, 001800C7718, 000FFFFCC80)
000FFFFC670  0018015AD54 (00800001880, 0080003A500, 0080003A570, 00000000000)
000FFFFC6D0  0018013FC8B (00800001880, 0080003A500, 0080003A570, 00000000000)
000FFFFC6D0  0010044E42A (00000000020, 8080808080808080, 0018004AE3E, 00180049D20)
000FFFFCCE0  0018004AEAA (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0  00180048846 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0  001800488F4 (00000000000, 00000000000, 00000000000, 00000000000)
End of stack trace

And the Function column is stable, only a few args changes during different tries (the first argument of function 00180070B8B).

@dscho
Copy link
Member

dscho commented Jun 15, 2020

Could you test with the latest snapshot? There have been a couple bug fixes in the Cygwin runtime v3.1.5, and the snapshot should come with an MSYS2 runtime based on that Cygwin version (you can always verify by looking at /etc/package-versions.txt).

@gdh1995
Copy link
Author

gdh1995 commented Jun 16, 2020

The Portable Git 64bit from commit 4df0b59, which is still using msys2-runtime v3.1.4-2, still has such an issue.

@gdh1995
Copy link
Author

gdh1995 commented Jun 16, 2020

Well, I downloaded git-for-windows/MSYS2-packages@f4d50b1 , went to /usr/src/MSYS2-packages/msys2-runtime, compiled the 3.1.5 version of msys2-runtime, and get a latest msys-2.0.dll. Then mintty.exe works (when called from a latest /usr/bin/bash.exe) again.

Update: I'd like to keep this issue open until a new stable version of Git for Windows gets released and this crash disappears in it, or if you managers like you may close it at once.

@dscho
Copy link
Member

dscho commented Jun 16, 2020

Indeed, there has not been any snapshot since I had upgraded both MinTTY and MSYS2 runtime. However, a build is running right now, and once it succeeds (hopefully...) the snapshot should then be uploaded for you to test.

@gdh1995
Copy link
Author

gdh1995 commented Jun 17, 2020

Oh it seems that this issue disappears in commit 3c88881 .

@gdh1995 gdh1995 closed this as completed Jun 17, 2020
@dscho
Copy link
Member

dscho commented Jun 17, 2020

Great!

FWIW it was probably not that commit, but the update to MinTTY and/or MSYS2 runtime that happened in the meantime.

@dscho dscho added this to the Next release milestone Jun 17, 2020
dscho added a commit to git-for-windows/build-extra that referenced this issue Jun 17, 2020
Under certain circumstances, the Git Bash window (MinTTY) [would
crash frequently](git-for-windows/git#2687),
which has been addressed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@NathanGibbs3
Copy link

Had the same Issue on Windows 7 32 bit.
Installing the Snapshot for Thu, 18 Jun 2020 fixed it.
Thanks. 😄

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

3 participants