<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 - Infinite recursion in StackProtector::HasAddressTaken due to self-referencing code in dead basic block"
   href="https://bugs.llvm.org/show_bug.cgi?id=40436">40436</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Infinite recursion in StackProtector::HasAddressTaken due to self-referencing code in dead basic block
          </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>Linux
          </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>mikael.holmen@ericsson.com
          </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=21376" name="attach_21376" title="reproducer">attachment 21376</a> <a href="attachment.cgi?id=21376&action=edit" title="reproducer">[details]</a></span>
reproducer

Reproduce with

llc -mtriple=x86_64-unknown-unknown -start-before=stack-protector
-stop-after=stack-protector stack-protector-unreachable-code.ll

The input looks like this:

define void @f() sspreq {
entry:
  %ai = alloca i8, align 1
  ret void

dead:
  %user = select i1 undef, i8* %ai, i8* %user
  unreachable
}

The problem occurs when StackProtector::HasAddressTaken is called on

   %ai = alloca i8, align 1

and then

  %user = select i1 undef, i8* %ai, i8* %user

since HasAddressTaken will be called on

  %user = select i1 undef, i8* %ai, i8* %user

over and over again until the stack is blown.

Since the instruction is in a unreachable basic block the input is ok even if
it normally isn't.</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>