librelist archives

« back to archive

general example broken?

general example broken?

From:
Han-Wen Nienhuys
Date:
2012-03-13 @ 15:36
hanwen@ploink:~/vc/libgit2/examples$ LD_LIBRARY_PATH=../build/ ./general
*Hex to Raw*
Raw 20 bytes: [�na%�)9����i*�����]

*Raw to Hex*
SHA hex string: fd6e612585290339ea8bf39c692a7ff6a29cb7c3

*Raw Object Read*
Segmentation fault

GDB:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b8db39 in git_cache_get (cache=0x7fffffffe290, oid=0x7fffffffe150)
    at /home/hanwen/vc/libgit2/src/cache.c:63
63			node = cache->nodes[hash & cache->size_mask];
(gdb) p cache->nodes
$1 = (git_cached_obj **) 0x7fffffffe5b2
(gdb) p cache->size_mask
$2 = 140737488348685
(gdb) p hash
$3 = 627142397

this is on

commit a17e882fab4e190d5a052cbc9cf6a238a9166a7c
Merge: ad87ccb 0e8144f
Author: Vicent Martí <tanoku@gmail.com>

machine is a x86_64 Ubuntu lucid machine.

is the example supposed to work?  Valgrind also warns of suspect actions

SHA hex string: fd6e612585290339ea8bf39c692a7ff6a29cb7c3
==6998== Conditional jump or move depends on uninitialised value(s)
==6998==    at 0x4E3E9FF: git_repository_odb__weakptr (repository.c:312)
==6998==    by 0x4E3EAF1: git_repository_odb (repository.c:336)
==6998==    by 0x401CB4: main (general.c:77)
==6998==
==6998== Use of uninitialised value of size 8
==6998==    at 0x4E3EA2B: git_repository_odb__weakptr (repository.c:314)
==6998==    by 0x4E3EAF1: git_repository_odb (repository.c:336)
==6998==    by 0x401CB4: main (general.c:77)
==6998==
==6998== Use of uninitialised value of size 8
==6998==    at 0x4E3EABE: git_repository_odb__weakptr (repository.c:330)
==6998==    by 0x4E3EAF1: git_repository_odb (repository.c:336)
==6998==    by 0x401CB4: main (general.c:77)
==6998==



-- 
Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen

Re: [libgit2] general example broken?

From:
Carlos Martín Nieto
Date:
2012-03-13 @ 16:49
On Tue, Mar 13, 2012 at 12:36:40PM -0300, Han-Wen Nienhuys wrote:
> hanwen@ploink:~/vc/libgit2/examples$ LD_LIBRARY_PATH=../build/ ./general
> *Hex to Raw*
> Raw 20 bytes: [�na%�)9����i*�����]
> 
> *Raw to Hex*
> SHA hex string: fd6e612585290339ea8bf39c692a7ff6a29cb7c3
> 
> *Raw Object Read*
> Segmentation fault
> 
> GDB:
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff7b8db39 in git_cache_get (cache=0x7fffffffe290, oid=0x7fffffffe150)
>     at /home/hanwen/vc/libgit2/src/cache.c:63
> 63			node = cache->nodes[hash & cache->size_mask];
> (gdb) p cache->nodes
> $1 = (git_cached_obj **) 0x7fffffffe5b2
> (gdb) p cache->size_mask
> $2 = 140737488348685
> (gdb) p hash
> $3 = 627142397
> 
> this is on
> 
> commit a17e882fab4e190d5a052cbc9cf6a238a9166a7c
> Merge: ad87ccb 0e8144f
> Author: Vicent Martí <tanoku@gmail.com>
> 
> machine is a x86_64 Ubuntu lucid machine.
> 
> is the example supposed to work?  Valgrind also warns of suspect actions

Not really. It doesn't check for any errors and the hashes don't exist in the
libgit2 repo. It's an example of the API, not an app.

   cmn

Re: [libgit2] general example broken?

From:
Han-Wen Nienhuys
Date:
2012-03-13 @ 17:01
On Tue, Mar 13, 2012 at 1:49 PM, Carlos Martín Nieto <carlos@cmartin.tk> wrote:
> On Tue, Mar 13, 2012 at 12:36:40PM -0300, Han-Wen Nienhuys wrote:
>> hanwen@ploink:~/vc/libgit2/examples$ LD_LIBRARY_PATH=../build/ ./general
>> *Hex to Raw*
>> Raw 20 bytes: [�na%�) 9����i* �����]
>>
>> *Raw to Hex*
>> SHA hex string: fd6e612585290339ea8bf39c692a7ff6a29cb7c3
>>
>> *Raw Object Read*
>> Segmentation fault
>>
>> GDB:
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x00007ffff7b8db39 in git_cache_get (cache=0x7fffffffe290, oid=0x7fffffffe150)
>>     at /home/hanwen/vc/libgit2/src/cache.c:63
>> 63                    node = cache->nodes[hash & cache->size_mask];
>> (gdb) p cache->nodes
>> $1 = (git_cached_obj **) 0x7fffffffe5b2
>> (gdb) p cache->size_mask
>> $2 = 140737488348685
>> (gdb) p hash
>> $3 = 627142397
>>
>> this is on
>>
>> commit a17e882fab4e190d5a052cbc9cf6a238a9166a7c
>> Merge: ad87ccb 0e8144f
>> Author: Vicent Martí <tanoku@gmail.com>
>>
>> machine is a x86_64 Ubuntu lucid machine.
>>
>> is the example supposed to work?  Valgrind also warns of suspect actions
>
> Not really. It doesn't check for any errors and the hashes don't exist in the
> libgit2 repo. It's an example of the API, not an app.

if it is using the API correctly, it should not crash from within the
libgit library, IMO.

-- 
Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen

Re: [libgit2] general example broken?

From:
Carlos Martín Nieto
Date:
2012-03-16 @ 09:17
On Tue, 2012-03-13 at 14:01 -0300, Han-Wen Nienhuys wrote:
> On Tue, Mar 13, 2012 at 1:49 PM, Carlos Martín Nieto <carlos@cmartin.tk> wrote:
> > On Tue, Mar 13, 2012 at 12:36:40PM -0300, Han-Wen Nienhuys wrote:
> >> hanwen@ploink:~/vc/libgit2/examples$ LD_LIBRARY_PATH=../build/ ./general
> >> *Hex to Raw*
> >> Raw 20 bytes: [�na%�) 9����i* �����]
> >>
> >> *Raw to Hex*
> >> SHA hex string: fd6e612585290339ea8bf39c692a7ff6a29cb7c3
> >>
> >> *Raw Object Read*
> >> Segmentation fault
> >>
> >> GDB:
> >>
> >> Program received signal SIGSEGV, Segmentation fault.
> >> 0x00007ffff7b8db39 in git_cache_get (cache=0x7fffffffe290, 
oid=0x7fffffffe150)
> >>     at /home/hanwen/vc/libgit2/src/cache.c:63
> >> 63                    node = cache->nodes[hash & cache->size_mask];
> >> (gdb) p cache->nodes
> >> $1 = (git_cached_obj **) 0x7fffffffe5b2
> >> (gdb) p cache->size_mask
> >> $2 = 140737488348685
> >> (gdb) p hash
> >> $3 = 627142397
> >>
> >> this is on
> >>
> >> commit a17e882fab4e190d5a052cbc9cf6a238a9166a7c
> >> Merge: ad87ccb 0e8144f
> >> Author: Vicent Martí <tanoku@gmail.com>
> >>
> >> machine is a x86_64 Ubuntu lucid machine.
> >>
> >> is the example supposed to work?  Valgrind also warns of suspect actions
> >
> > Not really. It doesn't check for any errors and the hashes don't exist in the
> > libgit2 repo. It's an example of the API, not an app.
> 
> if it is using the API correctly, it should not crash from within the
> libgit library, IMO.

And the text you quoted says it's not. The most likely reason it's
crashing there is because the odb pointer is bogus.

   cmn