Skip to content

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

Closed
@gdh1995

Description

@gdh1995
  • 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions