<html>
<head>
<base href="http://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 --- - Runtime crash because of leaking exception in a destructor when compiled with "-std=c++11 -g -O0" clang."
href="http://llvm.org/bugs/show_bug.cgi?id=20940">20940</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Runtime crash because of leaking exception in a destructor when compiled with "-std=c++11 -g -O0" clang.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.4
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>asg.msft@gmail.com
</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>Clang: version 3.4.
DESCRIPTION: Exception (throw 1;) is leaking in destructor although it's
guarded by catch(...). This causes the runtime to crash. This happens if the
code is compiled with "-std=c++11 -g -O0" clang option but doesn't happen with
"-std=c++11 -g -O2" option. Seems like optimization for -std=c++11 is
generating the incorrect code. Enabling the flag for exceptions with
"-fexceptions" didn't seem to matter. I've attached the respective .ii and .s
files.
I'm not sure whether the main trunk of clang has this issue. The clang++.exe
I'm using is from Android NDK. I filed a bug for Android as well.
I minimized the code to the following in my app.
-------------------
Contents of foo.cpp
-------------------
void func()
{
class CFoo
{
public:
CFoo() {}
~CFoo()
{
// throw 1 leaks and terminate is called if compiled
// with "-std=c++11 -g -O0".
// There is no crash if compiled with "-std=c++11 -g -O2".
try { throw 1; }
catch (...) {}
}
};
{ CFoo a; }
}
----------------------
Compilation commands
----------------------
1)RUNTIME crash: App crashes while executing the "throw 1" stmt above when
compiled with:
clang++.exe -g -std=c++11 -O0 -c foo.cpp -o foo.o
.ARM.exidx dump:
0x0 <_Z4funcv>: 0x809b8480
Compact model index: 0
0x9b vsp = r11
0x84 0x80 pop {r11, r14}
0x30 <_ZZ4funcvEN4CFooC2Ev>: 0x1 [cantunwind]
0x44 <_ZZ4funcvEN4CFooD2Ev>: 0x1 [cantunwind]
Unwind table index '.ARM.exidx.text.__clang_call_terminate' at offset 0x45c
contains 1 entries:
0x0 <__clang_call_terminate>: 0x1 [cantunwind]
2)NO RUNTIME crash: App doesn't crash when compiled with:
clang++.exe -g -std=c++11 -O2 -c foo.cpp -o foo.o
.ARM.exidx dump:
Unwind table index '.ARM.exidx' at offset 0x3b8 contains 1 entries:
0x0 <_Z4funcv>: 0x1 [cantunwind]
Unwind table index '.ARM.exidx.text.__clang_call_terminate' at offset 0x3d4
contains 1 entries:
0x0 <__clang_call_terminate>: 0x1 [cantunwind]</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>