<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 --- - Exceptions broken with -m32 -g"
   href="https://llvm.org/bugs/show_bug.cgi?id=31545">31545</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Exceptions broken with -m32 -g
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>release blocker
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>labath@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ cat /tmp/a.cc
int foo(void) { return 0; }

int main() {
  try {
    throw 10;
  } catch (...) {
  }
  return 0;
}


$ .../clang++  -g -m32 /tmp/a.cc -o a.out && ./a.out
terminate called after throwing an instance of 'int'
Aborted

=> The app crashes due to uncaught exception even though it should be caught

Things to note:
- the problem goes away if I remove "-g" from the command line
- the problem goes away if I remove "-m32" from the command line
- the problem goes away if I remove the "foo" declaration from a.cc

If I look at the intermediate .S file, I see that the thing in common for all
these three scenarios is that the ".cfi_sections .debug_frame" directive
dissapears.

My guess to what is going on is:
- we look at the first function, see that it cannot throw an exception, but we
still want to generate unwind info for the debugger, so we decide to use the
.debug_frame section.
- the second function *does* use need the unwind info, but now it's too late to
change the section, so it still ends up in .debug_frame.
- now the exception unwinder cannot find the unwind info at runtime

This bug was introduced recently, but I don't have an exact commit for it. I am
hoping that the problem will be sufficiently obvious to someone who is familiar
with the code in question.</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>