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

Kill process by PID causing segfault in bash #1316

Closed
1 task done
drewnoakes opened this issue Oct 5, 2017 · 5 comments
Closed
1 task done

Kill process by PID causing segfault in bash #1316

drewnoakes opened this issue Oct 5, 2017 · 5 comments
Assignees
Milestone

Comments

@drewnoakes
Copy link

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

Setup

$ git --version --build-options
git version 2.14.2.windows.1
built from commit: 788debdfb6b794425a3b949dd1a0eb2425a72e96
sizeof-long: 4
machine: x86_64

$ cmd.exe /c ver
Microsoft Windows [Version 10.0.15063]

$ cat /etc/install-options.txt
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Disabled
Enable Symlinks: Enabled

Details

Using Bash.

$ bash
$ notepad.exe &
[1] 12568
$ ps -W | grep "notepad.exe"
     9300       0       0       9300  ?              0 11:53:38 C:\Windows\System32\notepad.exe
$ kill 9300
Segmentation fault (core dumped)
$ cat bash.exe.stackdump
Stack trace:
Frame        Function    Args
000FFFFAEE0  0018005D5DC (000FFFFE3F4, 80808000C0C0C0, FF0000FF0000, 000FFFFDE50)
000FFFFAF80  0018005EBEB (00000000064, 00000000000, 00000000000, 00000000000)
000FFFFB1D0  0018012426D (000FFFFB350, 001802FE968, 00000004ECC, 00000000004)
000FFFFBB80  0018005D911 (00180040000, F8B8005C0000, 000FFFFB570, 000FFFFB530)
000FFFFB570  7FFEF9C5A07D (00000000000, 000FFFFB400, 000F28E84E4, 00000000005)
000FFFFB570  7FFEF9BC9C58 (000FFFFC520, 00000002454, 000FFFFBD0E, 000FFFFBCD0)
00000000000  7FFEF9C590FE (000FFFFC401, 00000000000, 00000000000, 000FFFFC560)
00000000000  001800ECC50 (00000000000, 00000000000, 000FFFFC560, 00000000000)
00000000000  00180120B32 (006001C02B0, 00000000000, 00000000000, 00000000000)
000FFFFC680  001801210A9 (001800BB49C, 00000000000, 00000000000, 0000000000F)
000FFFFC680  00180121231 (006001C0D50, 006001C0210, 0010040E508, 006001C02F0)
000FFFFC680  0018011C8DB (006001C0D50, 006001C0210, 0010040E508, 006001C02F0)
000FFFFC680  00100427D41 (00000000020, 00000000004, 001005EC5B0, 00000000000)
000FFFFC680  001004607F8 (00100410FBB, 00000000000, 006001C0210, 00000000000)
00000000000  001004142AA (0000000001F, 00000000000, 00000000000, 00000000000)
00000000000  00100416707 (001FFFFFFFF, 000FFFFFFFF, 00100000000, 0060005BC40)
End of stack trace (more stack frames may be present)
  • What did you expect to occur after running these commands?

Process with specified PID should be killed, and Bash shouldn't segfault.

  • What actually happened instead?

Bash segfaulted. Process with specified PID unaffected.

@dscho
Copy link
Member

dscho commented Oct 5, 2017

Can you try with the latest snapshot at https://wingit.blob.core.windows.net/files/index.html?

@dscho
Copy link
Member

dscho commented Oct 5, 2017

kill 9300

Please also note that this is the correct invocation to kill MSYS2 programs, but for Win32 programs (such as notepad.exe) you need /usr/bin/kill -f 9300.

@drewnoakes
Copy link
Author

Thank you. I'll try the snapshot in a minute.

My script was using -f, but I found that on the command line it was failing.

$ kill -f 13832
bash: kill: f: invalid signal specification
$ ls -la `which kill`
-rwxr-xr-x 1 Drew 197609 201333 Sep 14 11:52 /usr/bin/kill*

@dscho
Copy link
Member

dscho commented Oct 5, 2017

$ kill -f 13832
bash: kill: f: invalid signal specification

Note that bash:. The kill you are calling is the Bash builtin. Not /usr/bin/kill.exe.

But I did not sit on my hands in the meantime, I investigated further and found out that the bug was introduced by some misguided "fix compiler warning" patch of mine.

Will keep you posted.

@dscho dscho self-assigned this Oct 5, 2017
@dscho dscho added this to the v2.14.2(2) milestone Oct 5, 2017
dscho added a commit to git-for-windows/build-extra that referenced this issue Oct 5, 2017
A crash when calling `kill <pid>` for a non-existing process [was
fixed](git-for-windows/git#1316).

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

@dscho I tested snapshot 34c1a97 and the problem is resolved. Thanks for the incredibly fast turnaround, and for all your work on this project.

dscho added a commit to git-for-windows/msys2-runtime that referenced this issue Dec 15, 2017
Turns out that these are actually not all that stupid (see
git-for-windows/git#1316).

We *have* to compile this code with -Wno-error=nonnull-compare.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to git-for-windows/msys2-runtime that referenced this issue Dec 15, 2017
Turns out that these comparisons are actually essential: otherwise e.g.
`kill <pid>` will simply segfault if `<pid>` does not refer to an MSYS2
process (see git-for-windows/git#1316 for a
real-world bug report).

We *have* to compile this code with -Wno-error=nonnull-compare.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants