<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
Sean Kelly wrote:
<blockquote
 cite="mid:7DFB3784-0F34-4825-AB81-BEADD6CC0D13@invisibleduck.org"
 type="cite">
  <pre wrap="">On Jan 16, 2011, at 9:54 AM, Rainer Schuetze wrote:

  </pre>
  <blockquote type="cite">
    <pre wrap="">Hi,

I have not updated to the latest version yet, but it seems that it's the first time that gc_addRange is called during initialization, and this hits the bug in the gc stub code (obviously, the return statements are missing for the "proxy is null" case).

Even if fixed, the proxy has the problem that anything that has been allocated until the proxy is switched, uses a different heap, because the C-Runtime is not shared between the DLLs. This will cause problems when trying to scan/collect objects.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Allocating memory from the GC before initializing the runtime results in undefined behavior.  If you're using gcstub though, the only thing that won't work is that allocated blocks won't be scanned for roots by the new GC, but this behavior isn't expected anyway.  The new GC doesn't own the memory allocated by the old GC.  Also, The roots and ranges are already transferred to the new GC. (see gc_setProxy), so the static data segment of the DLL will be scanned by the app's GC.
  </pre>
</blockquote>
<br>
Here's the code for rt_init(), which is called by LoadLibrary(), i.e.
using gcstub instead of the gc. It calls _moduleCtor() and
_moduleTlsCtor(). Therefore, any memory allocated by any static
constructors in the DLL will not be scanned for roots.<br>
<br>
<tt>extern (C) bool rt_init(ExceptionHandler dg = null)<br>
{<br>
    _d_criticalInit();<br>
<br>
    try<br>
    {<br>
        gc_init();<br>
        initStaticDataGC();<br>
        version (Windows)<br>
            _minit();<br>
        _moduleCtor();<br>
        _moduleTlsCtor();<br>
        runModuleUnitTests();<br>
        return true;<br>
    }<br>
    catch (Throwable e)<br>
    {<br>
        if (dg)<br>
            dg(e);<br>
        else<br>
            throw e;    // rethrow, don't silently ignore error<br>
    }<br>
    _d_criticalTerm();<br>
    return false;<br>
}</tt><br>
<br>
</body>
</html>