<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - r274162 (SafeStack) causes cryptographic code to miscompile"
   href="https://bugs.llvm.org/show_bug.cgi?id=32143">32143</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>r274162 (SafeStack) causes cryptographic code to miscompile
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>ed@80386.nl
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18054" name="attach_18054" title="Reduced testcase of the miscompilation">attachment 18054</a> <a href="attachment.cgi?id=18054&action=edit" title="Reduced testcase of the miscompilation">[details]</a></span>
Reduced testcase of the miscompilation

CloudABI is a runtime environment based on a subset of POSIX that allows for
strong sandboxing. CloudABI uses Clang as its C/C++ compiler with LLVM's
SafeStack enabled by default.

One of the lead developers of Bitcoin, Wladimir van der Laan, is currently
working on getting Bitcoin Core ported over to CloudABI:

<a href="https://laanwj.github.io/2017/03/02/porting-bitcoin-core-to-cloudabi.html">https://laanwj.github.io/2017/03/02/porting-bitcoin-core-to-cloudabi.html</a>

In the process, he discovered that some of Bitcoin's unit tests tend to fail
when SafeStack is enabled. He observed this when using LLVM/Clang 4.0-rc2:

<a href="https://github.com/NuxiNL/cloudabi-ports/issues/30">https://github.com/NuxiNL/cloudabi-ports/issues/30</a>

I've done some bisecting and discovered it's caused by SVN r274162:

270000 ok
272500 ok
273750 ok
274062 ok
274140 ok
274160 ok
274161 ok
274162 bad
274163 bad
274165 bad
274170 bad
274179 bad
274218 bad
274375 bad
275000 bad
280000 bad
296985 bad

Attached you can find a source file of a reduced test case that should build
both on CloudABI and non-CloudABI. When built with SafeStack enabled and -O2 or
higher set, it will call abort(). When built without SafeStack or when using
lower optimisation levels, it will print "O.K." and terminate successfully.

I will add this as a blocker for 4.0.</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>