From: Ævar Arnfjörð Bjarmason Date: Fri, 05 Aug 2022 08:04:46 GMT Subject: Re: [bug] Segfault in git commit when a hook has a broken shebang Message-ID: <220805.86pmhfru8a.gmgdl@evledraar.gmail.com> In-Reply-To: On Fri, Aug 05 2022, Đoàn Trần Công Danh wrote: > On 2022-08-05 08:45:02+0300, Ilya K wrote: >> Hello! I ran into a weird bug just now that is probably easier to show than >> explain: >> ❯ git init >> Initialized empty Git repository in /home/k900/test/.git/ >> ❯ echo '#!/usr/bin/oops' > .git/hooks/pre-commit >> ❯ chmod +x .git/hooks/pre-commit >> ❯ touch oops >> ❯ git add oops >> ❯ git commit -a >> fatal: cannot run .git/hooks/pre-commit: No such file or directory >> [1]    24580 segmentation fault (core dumped)  git commit -a >> This happens consistently with git 2.37.x, and I don't think it happened >> with git 2.36 or earlier. > > This seems to be a side-effect of a082345372, (hook API: fix v2.36.0 > regression: hooks should be connected to a TTY, 2022-06-07) > > Since it makes hooks run in "ungroup" manner, hence run-command will > pass NULL as first argument to notify_start_failure. > > This patch seems to fix the crash, however, I think we should remove > that clause entirely. Yes, thanks. I'm already working on a patch for this with a test, will send it in shortly...