sh.exe.stackdump when trying to use a pre-commit-msg hook

Whenever I try to use a pre commit hook to prepend the current branch name, a sh.exe.stackdump file is generated and the hook doesn't work. I've tried a number of other files which have been verified to work on other PC's leading me to believe it's not an issue with the hook itself.

I'm using git 2.18 on Windows 10. I've verified my PATH is correct, reinstalled git already and have no AV running other than Windows Defender.


Exception: STATUS_STACK_OVERFLOW at rip=7FFE4951EC07
rax=0000000000000010 rbx=0000000000000000 rcx=0000000000000010
rdx=000000000000000C rsi=00000000FFFFAA50 rdi=00007FFE3CA8B600
r8 =00000000FFFFA988 r9 =00000000FFFFA9C0 r10=00000000FFFFA000
r11=00000000FFE03EA0 r12=FFFFFFFFFFFFFFFF r13=00000000FFFFADC0
r14=000000000000014C r15=0000000000000000
rbp=00000000FFFFA9C0 rsp=00000000FFFFA978
program=C:\Program Files\Git\usr\bin\sh.exe, pid 17444, thread 
cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace:
Frame        Function    Args
000FFFFA9C0  7FFE4951EC07 (00000000104, 000FFFFAA38, 7FFE494FFE58, 00000000000)
000FFFFA9C0  7FFE494FD827 (7FFE3CA8B600, 7FFE3CA8B600, 00000000001, 00000230022)
000FFFFAA38  7FFE45B48A24 (7FFE49480000, 7FFE494FD7A0, 7FFE494E7AC0, 7FFFFFFEFFFF)
000FFFFAC00  7FFE45B488A1 (5E03000600010000, 5A4E5B7BB435, 000FFFFAAC0, 000FFFFADC0)
000FFFFAC00  7FFE45B48704 (7FFE3CA8B810, FFFFFFFFFFFFFFFF, 0000084E840, 7FFE3CA8B810)
000FFFFAC00  7FFE3C9F11A0 (000FFFFAC00, 0000084E840, 00000000190, 00000000000)
000FFFFAC00  7FFE3C9C4DCC (7FFE00000005, 7FFE3C9C4C10, 00000160000, 000007E4D80)
000FFFFB3D0  7FFE3C99F83E (4F004E004F0043, 02400540055, 00000000000, 00180010018)
000007E4D80  7FFE3C99EA38 (000000001D4, 000FFFFBA00, 000FFFFB760, 000FFFFB7F8)
000FFFFB760  7FFE3C9973EC (000FFFFB8D0, 000000001DC, 00000000000, 0018028E980)
000000001D4  7FFE45B58966 (00000000001, 00000000000, 0018022F490, 00000000001)
000000001D4  7FFE4882A103 (00000000020, 00000000000, 000FFFFBB20, 00000000001)
000000001D4  001800AB2B5 (000FFFFBAC0, 0018028E980, 00000000001, 00000000001)
000FFFFBD30  001800ABFF5 (00100410FBB, 001803213B0, 0060004E980, 001004E9740)
000FFFFBD30  0018011DE4B (00100410FBB, 001803213B0, 0060004E980, 001004E9740)
000FFFFBD30  00000FAE458 (00100410FBB, 001803213B0, 0060004E980, 001004E9740)
End of stack trace (more stack frames may be present)

One of the prepare-commit-msg files I've tried:


if [ -z "$BRANCHES_TO_SKIP" ]; then
  BRANCHES_TO_SKIP=(master develop)

BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME=$(echo "$BRANCH_NAME" | sed -E 's/([0-9]+-[0-9]+)-.*/\1/')

echo Prepending branch name $BRANCH_NAME

BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")

if [ -n "$BRANCH_NAME" ] && ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $BRANCH_IN_COMMIT -ge 1 ]]; then
  sed -i.bak -e "1s/^/$BRANCH_NAME /" $1

1 answer

  • answered 2018-08-09 04:58 VonC

    I've verified my PATH is correct

    Still: for testing, unzip PortableGit-2.18.0-64-bit.7z.exe in C:\Git, and use a simplified PATH (in a CMD, just for testing)

    set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
    set GH=C:\Git
    set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%MAVEN_HOME%\bin;%PATH%

    Then, in that CMD, try again your commit in your repo with that hook.