[llvm-bugs] [Bug 33220] New: Exception handling bug with mingw-w64

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 30 01:08:09 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33220

            Bug ID: 33220
           Summary: Exception handling bug with mingw-w64
           Product: new-bugs
           Version: 4.0
          Hardware: PC
                OS: other
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: svyatoslav.scherbina at jetbrains.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 18533
  --> https://bugs.llvm.org/attachment.cgi?id=18533&action=edit
test

$ cat bug.cpp

class Foo {
    public:
        ~Foo() {}
};

void __attribute__((noinline)) bar() {
    Foo foo;
    throw 42;
}

int main() {
    try {
        bar();
    } catch (int x) {
    }
    return 0;
}


The attached program doesn't run right if compiled by clang++ with '-O2' for
x86_64-w64-mingw32 (tested with mingw-w64 6.3.0).
The program abnormally terminates instead of catching the exception:

$ clang++ -O2 -target x86_64-w64-mingw32 bug.cpp && ./a.exe

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
terminate called after throwing an instance of 'int'


The bug seems to be triggered by the function 'bar' which has personality
function '__gxx_personality_seh0' specified but doesn't have any landingpad
after the optimization:

___________
; Function Attrs: noinline noreturn uwtable
define void @_Z3barv() local_unnamed_addr #0 personality i8* bitcast (i32
(...)* @__gxx_personality_seh0 to i8*) {
entry:
  %exception = tail call i8* @__cxa_allocate_exception(i64 4) #3
  %0 = bitcast i8* %exception to i32*
  store i32 42, i32* %0, align 16, !tbaa !2
  tail call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*),
i8* null) #4
  unreachable
}
___________

-- 
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/20170530/d6ecd3b0/attachment.html>


More information about the llvm-bugs mailing list