[LLVMbugs] [Bug 11468] New: Clang incorrectly handles exceptions in presence of stack aligned variables

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Dec 2 11:27:46 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=11468

             Bug #: 11468
           Summary: Clang incorrectly handles exceptions in presence of
                    stack aligned variables
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: samsonov at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


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

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list