Re: [Gc] Re: Program broken

Ivan Maidanski ivmai at mail.ru
Wed Sep 23 09:28:44 PDT 2009


Hi!

Hugh <up2dream at gmail.com> wrote:
> > > Hi,
> > >
> > > My program often broke on line marked with "*". The error is First-chance
> > > exception at 0x00000000 in HostApp.exe: 0xC0000005: access violation read
> > > 0x00000000 .
> > >
> > > Any help will be appreciated.
> > >
> > > inline gc_cleanup::gc_cleanup() {
> > >     GC_finalization_proc oldProc;
> > >     void* oldData;
> > >     void* base = GC_base( (void *) this );
> > >     if (0 != base)  {
> > >       // Don't call the debug version, since this is a real base address.
> > > ********      GC_register_finalizer_ignore_self( *****
> > >         base, (GC_finalization_proc)cleanup, (void*) ((char*) this -
> (char*)
> > > base),
> > >         &oldProc, &oldData );
> >
> > There is no pointer dereference in this line, so it shouldn't produce SEGV.
> > I guess you mean the SEGV is somewhere in GC_register_finalizer_ignore_self
> (), right? If yes, could you
> > point to that place?
> >
> > >       if (0 != oldProc) {
> > >         GC_register_finalizer_ignore_self( base, oldProc, oldData, 0,
> 0 );}}}
> >
> > Bye.
> >
> It's terrible. I can't step into that function.

Use /Zi option when compiling gc.lib

> I think it may be that gc collect sth. that shouldn't be collected.

You hide pointers, right? Otherwise, do you suspect the GC is broken?

> How can I
> know a object is already collected?

GC_base(p) should be 0 if p has been collected (but this is not guaranteed since the memory might be already reused by other objects).

>
> thanks a lot.


More information about the Gc mailing list