-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Description
| Bugzilla Link | 11468 |
| Resolution | FIXED |
| Resolved on | Jul 30, 2012 03:55 |
| Version | trunk |
| OS | All |
| Attachments | Clang exceptions test |
| Reporter | LLVM Bugzilla Contributor |
| CC | @asl,@d0k,@echristo,@efriedma-quic,@eugenis,@kcc |
Extended Description
On fresh clang from trunk.
Reproducible both on Mac OS and Linux.
Clang seem to incorrectly restore value of callee-safe registers
during stack unwinding (when exception is thrown). This happens in
presence of aligned stack variables. Clang inserts asm instruction that
aligns %rsp but this isn't reported to unwinder. See this reproducer:
$ cat exception_test.cc
#include <stdio.h>
void TouchR15AndThrow(const char& arg) {
volatile int n attribute((aligned(32))) = 0;
asm volatile ("nop" : : : "r15"); // force to save r15 on stack
throw arg;
}
int main() {
register int *a asm ("r15");
fprintf(stderr, "before throw: %p\n", a);
try {
TouchR15AndThrow('c');
} catch (const char&) { }
fprintf(stderr, "after catch: %p\n", a);
return 0;
}
$ ../build/Release+Asserts/bin/clang++ -O2 exception_test.cc
$ ./a.out
before throw: 0x7fff5fbff968
after catch: 0x7fff702de650
More data, including parts of objdump and DWARF can be found here:
: http://code.google.com/p/address-sanitizer/issues/detail?id=13#c1