tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] tccpe.c / resolve_sym() leaks LoadLibrary() handles


From: egodust
Subject: Re: [Tinycc-devel] tccpe.c / resolve_sym() leaks LoadLibrary() handles
Date: Mon, 28 Apr 2008 18:31:30 +0100

I don't think you can, each dll name points back to the DLL (via
index) that loaded it, I haven't investigated it fully yet though.

On Mon, Apr 28, 2008 at 6:27 PM, grischka <address@hidden> wrote:
> Can't you just store the DLL-handle into the DLLReference structure?
>
>  --- grischka
>
>  From: "egodust"
>
>
> > Heyas,
>  >
>  > When a compiled TCC binary image is memory linked, resolve_sym() is
>  > given the symbol to find, it looks
>  > for the assocated DLL (using DEF file info) and calls LoadLibrary(),
>  > using GetProcAddress() to get the function
>  > pointer.
>  >
>  > This is problematic:
>  >
>  > 1. LoadLibrary() is called, per symbol, if multiple symbols from the
>  > same DLL are used, LoadLibrary() is called
>  >     per symbol.
>  >
>  > 2. LoadLibrary() is referenced counted and might overflow for many symbols
>  >
>  > 3. FreeLibrary() is never called, which means the DLLs are not freed,
>  > until process shutdown
>  >
>  > Imagine an application has loaded a custom dll (foo.dll) which TCC
>  > also LoadLibrary()s, the app then FreeLibrary()'s
>  >     at some point, but resolve_sym() has messed with the refcnt so the
>  > DLL can't be unloaded until exit(0)
>  >
>  > -
>  >
>  > resolve_sym() should defer loading libraries to another function which
>  > keeps track of the DLLs that have
>  > been LoadLibrary()'d, so that tcc_delete() can free them, it also
>  > means that LoadLibrary() is only called
>  > once per DLL when it needs to be mapped, and other symbols in the same
>  > DLL use the same handle with
>  > GetProcAddress()?
>  >
>  > Kind Regards,
>  > Sam
>  >
>  >
>  > _______________________________________________
>  > Tinycc-devel mailing list
>  > address@hidden
>  > http://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
>  _______________________________________________
>  Tinycc-devel mailing list
>  address@hidden
>  http://lists.nongnu.org/mailman/listinfo/tinycc-devel
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]