Bug 40501

Summary: crash in git format-patch --output with multiple commits (due to double free)
Product: Sisyphus Reporter: Ivan Zakharyaschev <imz>
Component: gitAssignee: placeholder <placeholder>
Status: NEW --- QA Contact: qa-sisyphus
Severity: minor    
Priority: P5 CC: glebfm, ldv, placeholder
Version: unstable   
Hardware: x86_64   
OS: Linux   

Description Ivan Zakharyaschev 2021-07-15 16:04:42 MSK
git format-patch --output with multiple commits crashes.

(The error message when it crashes can be different between different runs of the same command.)

Here is how I reproduce this (in hasher):

[builder@localhost ~]$ cat /.in/test-git-format-patch-segfault.sh 
#!/bin/sh -efuC
set -o pipefail

# set up
case "${1-}" in
    --ini*)
	mkdir tmp-workdir
	cd tmp-workdir
	git init
	echo a >a
	git add a
	git commit -m A
	echo b >b
	git add b
	git commit -m B
	echo c >c
	git add c
	git commit -m C
	;;
    *)
	cd tmp-workdir
	;;
esac

# test
git format-patch @^^..@ --output=out.txt
[builder@localhost ~]$ git config --global user.email "you@example.com"
[builder@localhost ~]$   git config --global user.name "Your Name"
[builder@localhost ~]$ /.in/test-git-format-patch-segfault.sh --ini
Initialized empty Git repository in /usr/src/tmp-workdir/.git/
[master (root-commit) 09a1525] A
 1 file changed, 1 insertion(+)
 create mode 100644 a
[master 2cc5aff] B
 1 file changed, 1 insertion(+)
 create mode 100644 b
[master e029363] C
 1 file changed, 1 insertion(+)
 create mode 100644 c
0001-B.patch
free(): double free detected in tcache 2
/.in/test-git-format-patch-segfault.sh: line 26: 236210 Aborted                 git format-patch @^^..@ --output=out.txt
[builder@localhost ~]$ /.in/test-git-format-patch-segfault.sh      
0001-B.patch
0002-C.patch
[builder@localhost ~]$ /.in/test-git-format-patch-segfault.sh 
0001-B.patch
free(): double free detected in tcache 2
/.in/test-git-format-patch-segfault.sh: line 26: 236221 Aborted                 git format-patch @^^..@ --output=out.txt
[builder@localhost ~]$ rpm -q git glibc-core
git-2.29.3-alt2.x86_64
glibc-core-2.32-alt3.x86_64
Comment 1 Ivan Zakharyaschev 2021-07-15 16:06:55 MSK
(Ответ для Ivan Zakharyaschev на комментарий #0)
> git format-patch --output with multiple commits crashes.
> 
> (The error message when it crashes can be different between different runs
> of the same command.)

On another system, with different commits, it was "malloc(): unaligned tcache chunk detected"