[libcxx-commits] [libcxxabi] r361039 - [libcxxabi] Add a test for invalid assumptions on the alignment of exceptions

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 17 07:53:30 PDT 2019


Author: ldionne
Date: Fri May 17 07:53:29 2019
New Revision: 361039

URL: http://llvm.org/viewvc/llvm-project?rev=361039&view=rev
Log:
[libcxxabi] Add a test for invalid assumptions on the alignment of exceptions

rdar://problem/49864414

Added:
    libcxxabi/trunk/test/exception_object_alignment.2.pass.cpp

Added: libcxxabi/trunk/test/exception_object_alignment.2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/exception_object_alignment.2.pass.cpp?rev=361039&view=auto
==============================================================================
--- libcxxabi/trunk/test/exception_object_alignment.2.pass.cpp (added)
+++ libcxxabi/trunk/test/exception_object_alignment.2.pass.cpp Fri May 17 07:53:29 2019
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: libcxxabi-no-exceptions
+
+// This test checks that the compiler does not make incorrect assumptions
+// about the alignment of the exception (only in that specific case, of
+// course).
+//
+// There was a bug where Clang would emit a call to memset assuming a 16-byte
+// aligned exception even when back-deploying to older Darwin systems where
+// exceptions are 8-byte aligned, which caused a segfault on those systems.
+
+struct exception {
+    exception() : x(0) { }
+    virtual ~exception() { }
+    int x;
+};
+
+struct foo : exception { };
+
+int main() {
+    try {
+      throw foo();
+    } catch (...) {
+
+    }
+    return 0;
+}




More information about the libcxx-commits mailing list