<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 --- - _Unwind_Backtrace() can't get past functions with EH."
href="http://llvm.org/bugs/show_bug.cgi?id=21053">21053</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>_Unwind_Backtrace() can't get past functions with EH.
</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>C++11
</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>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Clang 3.4
Picked up from: From Android r9d NDK.
Description:
First issue:
When the functions don't have try-catch in them the back trace (code given
below which uses _Unwind_Backtrace() and _Unwind_GetIP()) works fine and the IP
gets updated and prints all the functions walking down the stack.
Whereas if any of the functions have a try-catch block, _Unwind_GetIP() can't
get past that function. So it keeps looping around that IP indefinitely.
Second issue: The return code for _Unwind_Backtrace() is _URC_FAILURE.
I'm not sure whether the main trunk clang has the same issue. But Android's
NDK's clang definitely reproduces this. I filed a bug for Android as well.
Compilation command:
clang++.exe -target armv7-none-linux-androideabi -O0 -g -funwind-tables
-fexceptions -fno-omit-frame-pointer -std=c++11 -c foo.cpp -o foo.o
Sample code: foo.cpp:
#include <unwind.h>
_Unwind_Reason_Code trace_func(struct _Unwind_Context *context, void* arg)
{
void *ip = (void *)_Unwind_GetIP(context);
if(nullptr == ip)
// ip is never nullptr. Further if the context is from a function
// that has try-catch block, it can't move beyond that frame.
return _URC_END_OF_STACK;
else
return _URC_NO_REASON;
}
void func3()
{
_Unwind_Backtrace(trace_func, nullptr);
}
void func2() {
try { func3(); }
catch(...){}
}
void func1() { func2(); }
int main()
{
func1();
return 0;
}
EXPECTED RESULTS:
For the above program I expect the stack back trace to be (of course once I
resolve the symbols with dladdr):
_Unwind_Backtrace
func3()
func2()
func1()
main()
...
ACTUAL RESULTS:
_Unwind_Backtrace
func3()
func2()
func2()
func2()
ad infinitum
When I remove the try-catch though, it works fine and reports the results as in
EXPECTED results above. Please let me know if you need more details.
Thanks.</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>