<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
    <link href="chrome://translator/skin/floatingPanel.css"
      type="text/css" rel="stylesheet">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hello,<br>
    <br>
    I'm just bitten by some occasional finalize exceptions in a wxd
    program I'm writing on a OpenSuse 64 bit linux host with dmd 2.64.2.<br>
    <br>
    I was able to track it down to a bug in wxd, where the wxObject
    destructor tried to remove the object from a static map.<br>
    <br>
    some code from wxObject:<br>
    <br>
            ~this()<br>
            {<br>
                Dispose();<br>
            }<br>
    <br>
            public /+virtual+/ void Dispose()<br>
            {<br>
                if (wxobj != IntPtr.init)<br>
                {<br>
                //    bool still_there = RemoveObject(wxobj);<br>
    <br>
                //    lock (typeof (wxObject)) {<br>
                        if (memOwn /*&& still_there*/)<br>
                        {<br>
                            dtor();<br>
                        }<br>
                //    }<br>
                    <br>
                    RemoveObject(wxobj);<br>
                    wxobj = IntPtr.init;<br>
                //    memOwn = false;<br>
                }<br>
                //GC.SuppressFinalize(this);<br>
            }<br>
            <br>
            // Removes a registered object.<br>
            // returns true if the object is found in the<br>
            // Hashtable and is removed (for Dispose)<br>
    <br>
            public static bool RemoveObject(IntPtr ptr)<br>
            {<br>
                bool retval = false;<br>
    <br>
                if (ptr != IntPtr.init)<br>
                {<br>
                    if(ptr in objects) {<br>
                      //gw 20131207 objects.remove(ptr); <-- here the
    application goes boom, so i replaced it with the following line<br>
                      objects[ptr] = null;<br>
                      retval = true;<br>
                    }<br>
                }<br>
                <br>
                return retval;<br>
            }<br>
    <br>
            // Hashtable to associate C++ objects with D references<br>
            private static wxObject[IntPtr] objects;<br>
    <br>
    <br>
    <br>
    As you can see, the problem is that wxObject destructor tried to
    remove an entry from a static AA. Replacing the removal with just
    nulling the value solves the problem. But now I have to implement a
    cyclic cleanup routine wich removes the nulls from the AA. I really
    don't want to do that.<br>
    <br>
    I suspect that the AA reorganized (with allocation) when an element
    is removed. I think it is a good idee if this can be delayed until
    the next insert, so that remove can be used in finalizers. <br>
    <br>
    I also don't have a clue why the object gets collected when it is
    referenced in the static map. <br>
    <br>
    <br>
    Gerrit Wichert <br>
    <br>
    <br>
    <br>
    <br>
    <div style="bottom: auto; left: 12px; right: auto; top: 799px;
      display: none;" class="translator-theme-default"
      id="translator-floating-panel">
      <div title="Zum übersetzen klicken"
        id="translator-floating-panel-button"></div>
    </div>
  </body>
</html>