libgit2/libgit2 — Issue #465: git_status_foreach segfaults on repository
Author: xpaulbettsx
Created: 2011-10-26 05:38:41+00:00
State: open
Labels: bug

Using the repo here: http://cl.ly/0h1N0k0F0X3i43292L3B, calling git_status_foreach on this repo results in a failed assertion (or segfault, depending on if the assert is compiled in):

(a88.10d0): Break instruction exception - code 80000003 (first chance)
eax=00000004 ebx=00000000 ecx=0209196a edx=10b60004 esi=0000006f edi=10b5f134
eip=55ab1f34 esp=10b5c400 ebp=10b5ceb0 iopl=0 nv up ei pl zr na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000246
git2!_wassert+0xb64:
55ab1f34 cc int 3
0:007> kn100
# ChildEBP RetAddr
00 10b5ceb0 55a9676d git2!_wassert+0xb64 [f:\dd\vctools\crt_bld\self_x86\crt\src\assert.c @ 325]
01 10b5cec4 55a93eb4 git2!git_tree_entry_type+0x1d [c:\users\administrator\desktop\libgit2\src\tree.c @ 163]
02 10b5cee8 55a93bb1 git2!process_folder+0x24 [c:\users\administrator\desktop\libgit2\src\status.c @ 188]
03 10b5cf0c 55a93b11 git2!determine_status+0x41 [c:\users\administrator\desktop\libgit2\src\status.c @ 256]
04 10b5cf84 55a94784 git2!dirent_cb+0x1e1 [c:\users\administrator\desktop\libgit2\src\status.c @ 396]
05 10b5cfb4 55a93f5b git2!alphasorted_futils_direach+0xa4 [c:\users\administrator\desktop\libgit2\src\status.c @ 659]
06 10b5cfe4 55a93bb1 git2!process_folder+0xcb [c:\users\administrator\desktop\libgit2\src\status.c @ 209]
07 10b5d008 55a93b11 git2!determine_status+0x41 [c:\users\administrator\desktop\libgit2\src\status.c @ 256]
08 10b5d080 55a94784 git2!dirent_cb+0x1e1 [c:\users\administrator\desktop\libgit2\src\status.c @ 396]
09 10b5d0b0 55a936e7 git2!alphasorted_futils_direach+0xa4 [c:\users\administrator\desktop\libgit2\src\status.c @ 659]
0a 10b5f11c 0bac7998 git2!git_status_foreach+0x187 [c:\users\administrator\desktop\libgit2\src\status.c @ 454]

This occurs because we walk off the end of the index vector in dirent_cb