Subject: Re: git-fast-import crashes

From: Pierre Habouzit <[email-masked]>
Date: Tue, 16 Oct 2007 09:46:45 +0200

On Tue, Oct 16, 2007 at 07:13:31AM +0000, Shun Kei Leung wrote:
> Hi Pierre,
> 
> I have tested with your patch applied, and it still crashed badly.

  okay

> I compiled the b449f4c version and I got a different backtrace from
> GDB. I am still not sure about how the error occurs. I attached the
> memory usage from various command line tools.

  I believe you should rather test master as any of the strbuf stages is
broken for you, and that there has been some issues with strbuf fixed
lately (not only the patch I asked you to try, but also an issue with
empty strubufs, and you _need_ that patch).

> GDB output
> ===========
> 
> Program received signal EXC_BAD_ACCESS, Could not access memory.
> Reason: KERN_INVALID_ADDRESS at address: 0x756c7463
> 0x90018d0c in szone_realloc ()
> (gdb) bt
> #0  0x90018d0c in szone_realloc ()
> #1  0x90018898 in realloc ()
> #2  0x0001f8c8 in strbuf_grow (sb=0x75ef8, extra=0) at git-compat-util.h:223
> #3  0x0001fc14 in read_line (sb=0x75ef8, fp=0xa0001b9c, term=10) at strbuf.c:107
> #4  0x00002da8 in read_next_command () at fast-import.c:1599
> #5  0x0000742c in cmd_new_commit () at fast-import.c:2118
> #6  0x00007e80 in main (argc=1, argv=0xbffff828) at fast-import.c:2390
> (gdb) frame 3
> #3  0x0001fc14 in read_line (sb=0x75ef8, fp=0xa0001b9c, term=10) at strbuf.c:107
> 107                     strbuf_grow(sb, 1);
> (gdb) print *sb
> $1 = {
>   alloc = 60,
>   len = 23,
>   eof = 0,
>   buf = 0x5020b0 "D windows/packages/cdc/ces/adm"
> }
> (gdb) frame 2
> #2  0x0001f8c8 in strbuf_grow (sb=0x75ef8, extra=0) at git-compat-util.h:223
> 223             void *ret = realloc(ptr, size);
> (gdb) print (char *) ptr
> $2 = 0x5020b0 "D windows/packages/cdc/ces/adm"
> (gdb) print (char *)ret
> $3 = 0xd <Address 0xd out of bounds>

  This does not make sense, ptr should be either valid or NULL.
> The output of `leaks'
> =================
> 
> Process 27075: 88 nodes malloced for 2335 KB
> Process 27075: 6 leaks for 624 total leaked bytes.
> Leak: 0x005012b0  size=208      string 'EOT'
> Leak: 0x00501e60  size=128      string 'EOT'
> Leak: 0x00501c80  size=128      string 'EOT'
> Leak: 0x00500f10  size=64       string 'EOT'
> Leak: 0x00501fa0  size=64       string 'EOT'
> Leak: 0x00501f60  size=32
>         0x00000000 0x02008000 0x00000000 0x01000000     ................
>         0x02000000 0x0000001a 0x00000000 0x00000000     ................

  What I _really_ need is that you run your test into valgrind (the easy
way is to rename git-fast-import into git-fast-import.bin, and make
git-fast-import be a shell-script doing:

  exec valgrind --log-file /tmp/git-fast-import git-fast-import "$@"

  and please send to me the /tmp/git-fast-import.<pid> from the one that
crashes.

  And please do that on the most recent tip of master so that you have a
(at least believe to be) full and sane strbuf series. Thanks.

-- 
·O·  Pierre Habouzit
··O                                                [email-masked]
OOO                                                http://www.madism.org