Subject: valgrind hits in t9400 and t9401 (git cvsserver)

From: Jens Lehmann <[email-masked]>
Date: Fri, 02 Jul 2010 21:06:27 +0200

While working on a new configuration option for submodules i came
across a strange test failure today. My changes broke 19 different
tests in t9400 and t9401.

I found out that the failures were triggered by adding a function
call in cmd_diff_tree() right before the git_config() call. As I
had no idea how this change could possibly break those tests, I
decided to ask valgrind for its opinion. Using the --valgrind
option on t9400-git-cvsserver-server.sh I saw three hits. Unable
to imagine how my changes could provoke them, I tried plain next
et voila, the same hits showed up (as for master and pu).

I bisected the failure of t9400 to the commit ca8a36e "Merge branch
'js/remote-improvements'" (I CCed Jay because of that). I checked
this both on my desktop sytem (Fedora 12, Athlon 64 X2, gcc 4.4.3,
valgrind 3.5.0) and my Laptop (Fedora 13, Intel Core2 Duo T550,
gcc 4.4.4, valgrind 3.5.0) with the same result.

I searched the web but didn't find anything. As I am not at all
familiar with remote.c and cmd_fetch(), I'll now pass this to the
list.

Ideas?

valgrind says at ca8a36e for t9400-git-cvsserver-server.sh:

==3407== Invalid read of size 4
==3407==    at 0x80D0254: copy_ref (remote.c:786)
==3407==    by 0x80D0F01: get_fetch_map (remote.c:1242)
==3407==    by 0x8069CC5: cmd_fetch (builtin-fetch.c:123)
==3407==    by 0x804B0B4: handle_internal_command (git.c:244)
==3407==    by 0x804B26D: main (git.c:434)
==3407==  Address 0x4035fd0 is 80 bytes inside a block of size 82 alloc'd
==3407==    at 0x4004F1B: calloc (vg_replace_malloc.c:418)
==3407==    by 0x80E9790: xcalloc (wrapper.c:75)
==3407==    by 0x80D0483: alloc_ref_with_prefix (remote.c:769)
==3407==    by 0x80A6D92: get_remote_heads (connect.c:96)
==3407==    by 0x80E2BF2: get_refs_via_connect (transport.c:618)
==3407==    by 0x80E247D: transport_get_remote_refs (transport.c:791)
==3407==    by 0x8069C88: cmd_fetch (builtin-fetch.c:119)
==3407==    by 0x804B0B4: handle_internal_command (git.c:244)
==3407==    by 0x804B26D: main (git.c:434)
==3407==

==3407== Invalid read of size 4
==3407==    at 0x80D0240: copy_ref (remote.c:786)
==3407==    by 0x80D0406: copy_ref_list (remote.c:801)
==3407==    by 0x8067C1A: fetch_pack (builtin-fetch-pack.c:579)
==3407==    by 0x80E2A52: fetch_refs_via_pack (transport.c:654)
==3407==    by 0x80E25B3: transport_fetch_refs (transport.c:810)
==3407==    by 0x8069806: fetch_refs (builtin-fetch.c:456)
==3407==    by 0x8069D6E: cmd_fetch (builtin-fetch.c:584)
==3407==    by 0x804B0B4: handle_internal_command (git.c:244)
==3407==    by 0x804B26D: main (git.c:434)
==3407==  Address 0x4035f4c is 68 bytes inside a block of size 69 alloc'd
==3407==    at 0x4004F1B: calloc (vg_replace_malloc.c:418)
==3407==    by 0x80E9790: xcalloc (wrapper.c:75)
==3407==    by 0x80D0483: alloc_ref_with_prefix (remote.c:769)
==3407==    by 0x80A6D92: get_remote_heads (connect.c:96)
==3407==    by 0x80E2BF2: get_refs_via_connect (transport.c:618)
==3407==    by 0x80E247D: transport_get_remote_refs (transport.c:791)
==3407==    by 0x8069C88: cmd_fetch (builtin-fetch.c:119)
==3407==    by 0x804B0B4: handle_internal_command (git.c:244)
==3407==    by 0x804B26D: main (git.c:434)
==3407==

==3407== Invalid read of size 4
==3407==    at 0x80D0254: copy_ref (remote.c:786)
==3407==    by 0x80D0406: copy_ref_list (remote.c:801)
==3407==    by 0x8067C1A: fetch_pack (builtin-fetch-pack.c:579)
==3407==    by 0x80E2A52: fetch_refs_via_pack (transport.c:654)
==3407==    by 0x80E25B3: transport_fetch_refs (transport.c:810)
==3407==    by 0x8069806: fetch_refs (builtin-fetch.c:456)
==3407==    by 0x8069D6E: cmd_fetch (builtin-fetch.c:584)
==3407==    by 0x804B0B4: handle_internal_command (git.c:244)
==3407==    by 0x804B26D: main (git.c:434)
==3407==  Address 0x4035fd0 is 80 bytes inside a block of size 82 alloc'd
==3407==    at 0x4004F1B: calloc (vg_replace_malloc.c:418)
==3407==    by 0x80E9790: xcalloc (wrapper.c:75)
==3407==    by 0x80D0483: alloc_ref_with_prefix (remote.c:769)
==3407==    by 0x80A6D92: get_remote_heads (connect.c:96)
==3407==    by 0x80E2BF2: get_refs_via_connect (transport.c:618)
==3407==    by 0x80E247D: transport_get_remote_refs (transport.c:791)
==3407==    by 0x8069C88: cmd_fetch (builtin-fetch.c:119)
==3407==    by 0x804B0B4: handle_internal_command (git.c:244)
==3407==    by 0x804B26D: main (git.c:434)
==3407==