<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>40501</bug_id>
          
          <creation_ts>2021-07-15 16:04:42 +0300</creation_ts>
          <short_desc>crash in git format-patch --output with multiple commits (due to double free)</short_desc>
          <delta_ts>2021-07-15 16:06:55 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>git</component>
          <version>unstable</version>
          <rep_platform>x86_64</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ivan Zakharyaschev">imz</reporter>
          <assigned_to name="placeholder@altlinux.org">placeholder</assigned_to>
          <cc>glebfm</cc>
    
    <cc>ldv</cc>
    
    <cc>placeholder</cc>
    
    <cc>vt</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>200543</commentid>
    <comment_count>0</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2021-07-15 16:04:42 +0300</bug_when>
    <thetext>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 &quot;${1-}&quot; in
    --ini*)
	mkdir tmp-workdir
	cd tmp-workdir
	git init
	echo a &gt;a
	git add a
	git commit -m A
	echo b &gt;b
	git add b
	git commit -m B
	echo c &gt;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 &quot;you@example.com&quot;
[builder@localhost ~]$   git config --global user.name &quot;Your Name&quot;
[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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>200544</commentid>
    <comment_count>1</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2021-07-15 16:06:55 +0300</bug_when>
    <thetext>(Ответ для Ivan Zakharyaschev на комментарий #0)
&gt; git format-patch --output with multiple commits crashes.
&gt; 
&gt; (The error message when it crashes can be different between different runs
&gt; of the same command.)

On another system, with different commits, it was &quot;malloc(): unaligned tcache chunk detected&quot;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>