> > While building something on top of a GNAT-compiled library, I noticed that
> > repeatedly generating symbolic tracebacks led to a memory leak in my
> > program. I tracked this down to a missing close in libgnat, which I've
> > attempted to fix with the attached patch.
>
> Thanks for catching this.
>
> > I validated this fix locally with valgrind, as it wasn’t clear to me how to
> > add a test for this.
>
> I agree that there is no convenient way to test this.
>
> > Close C.Line_Str with the other debug streams, before closing the object
> > file. An absent section needs no extra guard: its region starts null and
> > System.Mmap.Free already accepts null.
>
> Yes, but this reasoning breaks privacy since Mapped_Stream is a private type,
> so I think that the logic of Close should match that of Open.  You could for
> example add a Has_Line_Str boolean component to Dwarf_Context and test it.
>

Thanks for taking a look; an updated patch is attached.

Cheers,

Andrew

Attachment: 0001-ada-Close-the-DWARF-line-string-stream.patch
Description: 0001-ada-Close-the-DWARF-line-string-stream.patch

Reply via email to