<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW " title="NEW --- - LLVMRunStaticConstructors crashes, FIX/DIFF INCLUDED" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24028&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=S83DM4ER39uoiHyPE-yaAbueBn6moPFXYO56gicR9k8&s=eqPDpXFCxDJFv5Qdy-n9xEcUSfjcrax7LYJJvkkt8Ys&e=">24028</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLVMRunStaticConstructors crashes, FIX/DIFF INCLUDED
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>MCJIT
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>llvm@dav1d.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14549" name="attach_14549" title="Diff which fixes the issue">attachment 14549</a> <a href="attachment.cgi?id=14549&action=edit" title="Diff which fixes the issue">[details]</a></span>
Diff which fixes the issue

The Problem is LLVMRunStaticConstructors might be run before finalizeObject was
called. Here is the patch:


--- ExecutionEngineBindings.cpp    2015-07-04 13:57:32.051159075 +0200
+++ ExecutionEngineBindings.cpp.new    2015-07-04 13:58:23.905707243 +0200
@@ -244,10 +244,12 @@
 }

 void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE) {
+  unwrap(EE)->finalizeObject();
   unwrap(EE)->runStaticConstructorsDestructors(false);
 }

 void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE) {
+  unwrap(EE)->finalizeObject();
   unwrap(EE)->runStaticConstructorsDestructors(true);
 }


Even though this patch works, I would like to see/discuss a better binding to
the underlaying ExecutionObject and exposing more of its functionallity, e.g.
addObject etc. and also finalizeObject, meaning the user can take care of
calling finalizeObject himself.

For all the people searching for a workaround, create an empty function or
global, and either call the function or try to get the address of the global.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>