Regression in patch add?

2018-04-15 Thread mqudsi
Hello all,

I'm currently running the latest version of git built from `master`, and
I'm running into what appears to be a regression in the behavior of the
piecewise `git add -p` when applying a manually edited chunk.

I first run `git add -p`, then manually edit a chunk (after hitting `s`
once, if it matters). The chunk originally contains the following:

```diff
# Manual hunk edit mode -- see bottom for a quick guide
@@ -20,7 +20,7 @@
"call dein#add('Shougo/dein.vim', {'rev': 'master'})

" Add or remove your plugins here:
-   " call dein#add('flazz/vim-colorschemes')
-   call dein#add('Haron-Prime/evening_vim')
+   call dein#add('flazz/vim-colorschemes')
+   call dein#add('danilo-augusto/vim-afterglow')

"core plugins that change the behavior of vim and how we use it globally
```

Under git 2.7.4, I can edit it to the following, which is accepted
without a problem:

```diff
# Manual hunk edit mode -- see bottom for a quick guide
@@ -20,7 +20,7 @@
"call dein#add('Shougo/dein.vim', {'rev': 'master'})

" Add or remove your plugins here:
-   " call dein#add('flazz/vim-colorschemes')
-   call dein#add('Haron-Prime/evening_vim')
+   call dein#add('flazz/vim-colorschemes')
+   call dein#add('Haron-Prime/evening_vim')

"core plugins that change the behavior of vim and how we use it globally
```

All I did here was remove one `+` line and manually add another (which
is a variant of the second `-` line).

Under git 2.17.0.252.gfe0a9ea, the same piece is opened in $VISUAL for
editing (and if left unmodified applies OK), but when modified in the
to the same exact value, after exiting the editor I receive the
following error from git:

error: patch fragment without header at line 15: @@ -25,7 +25,8 @@

I'm not sure what to make of this.

Thank you,

Mahmoud Al-Qudsi
NeoSmart Technologies




Invalid memory access in `git apply`

2017-11-08 Thread mqudsi
**Resending as it seems that the attachments caused the last email to wind up
in a black hole**

There seems to be bug in the `git apply` that leads to out-of-bounds memory
access when --ignore-space-change is combined with --inaccurate-eof and
applying a patch.

On occasion, this can lead to error output like the following:

 mqudsi@ZBook ~> git apply --ignore-space-change --ignore-whitespace
 --allow-overlap --inaccurate-eof without_whitespace.diff
 *** Error in `git': malloc(): memory corruption: 0x02543530 ***
 === Backtrace: =
 /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fdda79c77e5]
 /lib/x86_64-linux-gnu/libc.so.6(+0x8213e)[0x7fdda79d213e]
 /lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x54)[0x7fdda79d4184]
 
/lib/x86_64-linux-gnu/libc.so.6(_IO_file_doallocate+0x55)[0x7fdda79bd1d5]
 /lib/x86_64-linux-gnu/libc.so.6(_IO_doallocbuf+0x34)[0x7fdda79cb594]
 
/lib/x86_64-linux-gnu/libc.so.6(_IO_file_overflow+0x1c8)[0x7fdda79ca8f8]
 /lib/x86_64-linux-gnu/libc.so.6(_IO_file_xsputn+0xad)[0x7fdda79c928d]
 /lib/x86_64-linux-gnu/libc.so.6(fputs+0x98)[0x7fdda79be0c8]
 git[0x5386cd]
 git[0x538714]
 git[0x538940]
 git[0x40e220]
 git[0x410a10]
 git[0x41256e]
 git[0x412df7]
 git[0x415935]
 git[0x406436]
 git[0x40555c]

The original file being patched (clipboard.vim) and the patch file that I had
attempted to apply (without_whitespace.diff) are attached, along with the
full, unabridged output of the memory map as a result of the out-of-bounds
access (memory_map.txt).

The memory map output was generated under git 2.7.4; repeated attempts to
reproduce the memory map dump with both 2.7.4 and 2.15 produce the following
output:

     mqudsi@ZBook ~/.c/nvim> git apply --ignore-space-change  
--inaccurate-eof
 --whitespace=fix without_whitespace.diff
 fatal: BUG: caller miscounted postlen: asked 248, orig = 251, used = 
249

Mahmoud Al-Qudsi
NeoSmart Technologies

--Attachments--

* clipboard.vim: http://termbin.com/u25t
* without_whitespace.diff: http://termbin.com/bu9y
* memory_map.txt: http://termbin.com/cboz