[LLVMbugs] [Bug 21236] New: crash in ExitCXXTryStmt where top of EHStack does not contain EHCatchScope

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Oct 9 20:59:05 PDT 2014


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

            Bug ID: 21236
           Summary: crash in ExitCXXTryStmt where top of EHStack does not
                    contain EHCatchScope
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Testcase:

class exception {};

struct T {
  char a[33];
};

void foo() {
  try {
    const T& t = T();
  } catch (const exception& e) {
  }
}

Reproduce with "clang -O2".

This crashes in clang's llvm codegen but only with -O2. You can use -mllvm
-disable-llvm-optzns and it still crashes. 

nlewycky at ducttape:~$ llvm/Debug+Asserts/bin/clang -O2 x.cc
clang: /usr/local/google/home/nlewycky/llvm/include/llvm/Support/Casting.h:230:
typename llvm::cast_retty<To, From>::ret_type llvm::cast(Y&) [with X =
clang::CodeGen::EHCatchScope; Y = clang::CodeGen::EHScope; typename
llvm::cast_retty<To, From>::ret_type = clang::CodeGen::EHCatchScope&]:
Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
0  clang           0x0000000003e86b19 llvm::sys::PrintStackTrace(_IO_FILE*) +
38
1  clang           0x0000000003e86d96
2  clang           0x0000000003e86696
3  libpthread.so.0 0x00007f8ae8b88340
4  libc.so.6       0x00007f8ae7b9bbb9 gsignal + 57
5  libc.so.6       0x00007f8ae7b9efc8 abort + 328
6  libc.so.6       0x00007f8ae7b94a76
7  libc.so.6       0x00007f8ae7b94b22
8  clang           0x000000000162ec0a
9  clang           0x000000000162ceeb
clang::CodeGen::CodeGenFunction::ExitCXXTryStmt(clang::CXXTryStmt const&, bool)
+ 123

I think the top of the stack has a NormalAndEHCleanup:

(gdb) p EHStack.begin() 
$1 = {Ptr = 0x67a82a0 ""}
(gdb) p *(EHCleanupScope*)0x67a82a0
$7 = {<clang::CodeGen::EHScope> = {CachedLandingPad = 0x0, 
    CachedEHDispatchBlock = 0x0, EnclosingEHScope = {Size = 48}, {
      CommonBits = {Kind = 0}, CatchBits = {NumHandlers = 775}, CleanupBits = {
        IsNormalCleanup = 1, IsEHCleanup = 1, IsActive = 1, 
        TestFlagInNormalCleanup = 0, TestFlagInEHCleanup = 0, 
        CleanupSize = 24, FixupDepth = 0}, FilterBits = {NumFilters = 775}}}, 
  EnclosingNormal = {Size = 0}, EnclosingEH = {Size = -1}, NormalBlock = 0x0, 
  ActiveFlag = 0x0, ExtInfo = 0x0}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141010/5811c81f/attachment.html>


More information about the llvm-bugs mailing list