Subject: git fsck segmentation fault

From: Simon Hausmann <[email-masked]>
Date: Thu, 27 Nov 2008 18:14:06 +0100

Hi,

when running git fsck --full -v (version 1.6.0.4.26.g7c30c) on a medium sized
(930M) repository I get a segfault.

The backtrace indicates an infinite recursion. Here's the output from the last
few lines:

Checking commit ffffb0556074699814751f3b34526b3d6850c6f7
Checking blob ffffb4e9edf03e7f5643abc5603ca57e745c313d
Checking tree ffffde1114cdd0937cb798069b45f4ceadccd22f
Checking tree ffffe7e34be267ca55a6ae823f8bf31d7a8ef3cd
Checking blob ffffe8bbfc4d7adcb4e5fa00f1b4c99e26591b76
Checking tree ffffea81b8790b194ac215807165e3ff7f824320
Checking blob ffffec79ba618a429dee33bb0acb0ab36cb1310d
Checking tree fffff62eaba873e3ea3cfd7535e6ac514fd18332
Checking blob fffff6519569fac30b11b7bc830d61e296b7c5e2
Segmentation fault (core dumped)

gdb on the core file produces the following backtrace:

#0  0x0000000000487684 in unpack_object_header (p=0x26ad4c0, w_curs=0x7fff72f8a060, curpos=0x7fff72f8a058, sizep=0x7fff72f8a0c8) at sha1_file.c:1400
1400            base = use_pack(p, w_curs, *curpos, &left);

#0  0x0000000000487684 in unpack_object_header (p=0x26ad4c0, w_curs=0x7fff72f8a060, curpos=0x7fff72f8a058, sizep=0x7fff72f8a0c8) at sha1_file.c:1400
#1  0x000000000048827e in unpack_entry (p=0x26ad4c0, obj_offset=490508859, type=0x7fff72f8cd14, sizep=0x7fff72f8a004) at sha1_file.c:1693
#2  0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=490581247, type=0x7fff72f8cd14, sizep=0x7fff72f8a148) at sha1_file.c:1647
#3  0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=490679881, type=0x7fff72f8cd14, sizep=0x7fff72f8a1c8) at sha1_file.c:1647
#4  0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=490685453, type=0x7fff72f8cd14, sizep=0x7fff72f8a248) at sha1_file.c:1647
#5  0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=490689484, type=0x7fff72f8cd14, sizep=0x7fff72f8a2c8) at sha1_file.c:1647
#6  0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=490738466, type=0x7fff72f8cd14, sizep=0x7fff72f8a348) at sha1_file.c:1647
#7  0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=490744208, type=0x7fff72f8cd14, sizep=0x7fff72f8a3c8) at sha1_file.c:1647
#8  0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=490755670, type=0x7fff72f8cd14, sizep=0x7fff72f8a448) at sha1_file.c:1647
#9  0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491146004, type=0x7fff72f8cd14, sizep=0x7fff72f8a4c8) at sha1_file.c:1647
#10 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491148469, type=0x7fff72f8cd14, sizep=0x7fff72f8a548) at sha1_file.c:1647
#11 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491150324, type=0x7fff72f8cd14, sizep=0x7fff72f8a5c8) at sha1_file.c:1647
#12 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491150930, type=0x7fff72f8cd14, sizep=0x7fff72f8a648) at sha1_file.c:1647
#13 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491549282, type=0x7fff72f8cd14, sizep=0x7fff72f8a6c8) at sha1_file.c:1647
#14 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491552398, type=0x7fff72f8cd14, sizep=0x7fff72f8a748) at sha1_file.c:1647
#15 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491552652, type=0x7fff72f8cd14, sizep=0x7fff72f8a7c8) at sha1_file.c:1647
#16 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491553208, type=0x7fff72f8cd14, sizep=0x7fff72f8a848) at sha1_file.c:1647
#17 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491556704, type=0x7fff72f8cd14, sizep=0x7fff72f8a8c8) at sha1_file.c:1647
#18 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491560658, type=0x7fff72f8cd14, sizep=0x7fff72f8a948) at sha1_file.c:1647
#19 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491582507, type=0x7fff72f8cd14, sizep=0x7fff72f8a9c8) at sha1_file.c:1647
#20 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491604310, type=0x7fff72f8cd14, sizep=0x7fff72f8aa48) at sha1_file.c:1647
#21 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491614312, type=0x7fff72f8cd14, sizep=0x7fff72f8aac8) at sha1_file.c:1647
#22 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491666142, type=0x7fff72f8cd14, sizep=0x7fff72f8ab48) at sha1_file.c:1647
#23 0x0000000000488352 in unpack_entry (p=0x26ad4c0, obj_offset=491901113, type=0x7fff72f8cd14, sizep=0x7fff72f8cd08) at sha1_file.c:1647
#24 0x00000000004887ca in read_packed_sha1 (sha1=0x336ba64 "�W\004�\037d\203g��;v\032vF�>�R�", type=0x7fff72f8cd14, size=0x7fff72f8cd08) at sha1_file.c:1957
#25 0x00000000004889fe in read_object (sha1=0x336ba64 "�W\004�\037d\203g��;v\032vF�>�R�", type=0x7fff72f8cd14, size=0x7fff72f8cd08) at sha1_file.c:2047
#26 0x0000000000488bcc in read_sha1_file (sha1=0x26ad4c0 "", type=0x7fff72f8a060, size=0x1d3c923b) at sha1_file.c:2063
#27 0x000000000048f3fd in parse_tree (item=0x336ba60) at tree.c:224
#28 0x0000000000423a32 in mark_object (obj=0x336ba60, type=2, data=<value optimized out>) at builtin-fsck.c:102
#29 0x00000000004673bc in fsck_walk (obj=<value optimized out>, walk=0x423880 <mark_object>, data=0x336ba38) at fsck.c:26
#30 0x0000000000423a4a in mark_object (obj=0x336ba38, type=2, data=<value optimized out>) at builtin-fsck.c:105
#31 0x00000000004673bc in fsck_walk (obj=<value optimized out>, walk=0x423880 <mark_object>, data=0x66fff78) at fsck.c:26
#32 0x0000000000423a4a in mark_object (obj=0x66fff78, type=2, data=<value optimized out>) at builtin-fsck.c:105
#33 0x00000000004673bc in fsck_walk (obj=<value optimized out>, walk=0x423880 <mark_object>, data=0x66c9a28) at fsck.c:26
#34 0x0000000000423a4a in mark_object (obj=0x66c9a28, type=2, data=<value optimized out>) at builtin-fsck.c:105
#35 0x0000000000467299 in fsck_walk (obj=0x6bea7b0, walk=0x423880 <mark_object>, data=0x6bea7b0) at fsck.c:50
#36 0x000000000042390d in mark_object (obj=0x6bea7b0, type=1, data=<value optimized out>) at builtin-fsck.c:105
#37 0x00000000004672d1 in fsck_walk (obj=<value optimized out>, walk=0x423880 <mark_object>, data=0x3283fd0) at fsck.c:57
#38 0x000000000042390d in mark_object (obj=0x3283fd0, type=1, data=<value optimized out>) at builtin-fsck.c:105
#39 0x00000000004672d1 in fsck_walk (obj=<value optimized out>, walk=0x423880 <mark_object>, data=0x3283f88) at fsck.c:57
#40 0x000000000042390d in mark_object (obj=0x3283f88, type=1, data=<value optimized out>) at builtin-fsck.c:105
[...]

The stack trace in total has about ~80000 frames.

Does anyone have any suggestions on how to debug this?

Thanks,
Simon