[Gc] Re: Fwd: GC_free crash when used with FreeImage library

Eduard Urbach e.urbach at gmail.com
Tue Aug 7 10:59:10 PDT 2012


I haven't found "GC_print_heap_sects" but I tried GC_dump and printed the
pointer address on the console:

https://gist.github.com/3287750

If I understand the output correctly there is 1 managed heap section:
Section 0 from 0x9541000 to 0x9551000

And the image pointer is not in that section:
Pointer address to FreeImage_Unload: 0x95a1108

Note that even if I __instantly__ unload the loaded image from the memory
after loading it the program still segfaults:

    dib = FreeImage_Load(fif, filename);

    FreeImage_Unload(dib);


Tried version 7.2c as well, same problem.

If I may I summarize the problem in 1 sentence:
FreeImage_Unload somehow calls GC_free...instead of a "normal" free which
would be correct in this case.

On Sun, Aug 5, 2012 at 7:14 PM, Boehm, Hans <hans.boehm at hp.com> wrote:

> I agree that this is entirely consistent with calling GC_free on a
> location that either wasn't allocated through GC_malloc or friends, or has
> already been deallocated.  The interesting question is where the argument
> address came from.  A call to GC_print_heap_sects() will let you determine
> whether it's in a heap section managed by the collector.  If it's in a GC
> managed section, the next step would be to look for prior GC_free calls on
> the same location.
>
> Hans
>
> > -----Original Message-----
> > From: gc-bounces at linux.hpl.hp.com [mailto:gc-bounces at linux.hpl.hp.com]
> > On Behalf Of Ivan Maidanski
> > Sent: Sunday, August 05, 2012 1:28 AM
> > To: Eduard Urbach
> > Cc: Boehm GC
> > Subject: [Gc] Re: Fwd: GC_free crash when used with FreeImage library
> >
> > Hi Eduard,
> >
> > Sorry for the delay. I have no time to reproduce the sample. But it
> > looks when you call GC_free that memory is already freed.
> > May be someone else on the list has an idea what's wrong.
> >
> > Regards,
> > Ivan
> >
> > Sun, 15 Jul 2012 19:32:40 +0200 Eduard Urbach <e.urbach at gmail.com>:
> > > Hi Ivan,
> > >
> > > I'm copying this message to you because somehow my mailing list
> > membership
> > > is gone.
> > > Maybe you have a quick idea how to solve the problem.
> > >
> > > Regards,
> > > Eduard
> > >
> > > ---------- Forwarded message ----------
> > > From: Eduard Urbach <e.urbach at gmail.com>
> > > Date: Wed, Jul 11, 2012 at 11:47 AM
> > > Subject: GC_free crash when used with FreeImage library
> > > To: Boehm GC <gc at linux.hpl.hp.com>
> > >
> > >
> > > Hello everyone,
> > >
> > > I'm not sure if I'm doing something wrong: I have a fairly normal
> > > installation of bdwgc 7.3 and FreeImage 3.15.3 which is only used in
> > this
> > > part of my code:
> > > https://gist.github.com/3089309
> > >
> > > When executing FreeImage_Unload() the application segfaults at
> > >
> > >   Program received signal SIGSEGV, Segmentation fault.
> > >
> > >   GC_free (p=0x83e92d8) at malloc.c:495
> > >
> > >   sz = hhdr -> hb_sz;
> > >
> > >
> > > Even if I don't call FreeImage_Unload() the app crashes at the end.
> > >
> > > If you want to reproduce it, install
> > https://github.com/blitzprog/flua and
> > > execute the Graphics examples. They all segfault at termination.
> > >
> > >
> > > I tried disabling the GC with GC_disable() for that part of the code
> > but
> > > that shows no effect.
> > >
> > > I'm a bit confused right now, hope you can help me find the error
> > source or
> > > show me whether I did a trivial mistake..
> > >
> > >
> > > Regards,
> > >
> > > Eduard Urbach
> > >
> > >
> >
> > _______________________________________________
> > Gc mailing list
> > Gc at linux.hpl.hp.com
> > http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
>
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://napali.hpl.hp.com/pipermail/gc/attachments/20120807/e7b9317c/attachment.htm


More information about the Gc mailing list