Ideas for runtime loading of shared libraries.

Walter Bright newshound2 at digitalmars.com
Thu Mar 7 19:22:46 PST 2013


On 3/7/2013 6:18 PM, Daniel Murphy wrote:
> "Walter Bright" <newshound2 at digitalmars.com> wrote in message
> news:khban1$1lm2$1 at digitalmars.com...
>> On 1/2/2012 11:20 AM, Martin Nowak wrote:
>>>    - Libraries might not be unloaded as long as GC collected class
>>> instances
>>> still exist because
>>>      finalization fails otherwise.
>>
>> D doesn't guarantee that finalizers will run on GC allocated objects.
>> Therefore, when unloading a dll:
>>
>> 1. run a gc collection
>> 2. for all objects remaining on the heap
>>         if they have a finalizer and that finalizer points into the dll
>> code
>>              mark them as not having a finalizer
>
> What if their vtbl points into the dll code?
>
> What about delegates or function pointers that point there?

These are problems with *any* dynamic dll code. The answer is to tell the user 
"don't do that". The user should NEVER continue to use objects created by that 
dll or delegates/functionpointers/datapointers that refer to it.

The gc problem, however, is not tractable for the user, so it must be dealt with 
by us, and can be dealt with using the method I described.



More information about the Digitalmars-d mailing list