[llvm-bugs] [Bug 47515] New: clang-cl x86/Release inlined try-catch leads to access violation or std::length_error

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 14 02:40:04 PDT 2020


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

            Bug ID: 47515
           Summary: clang-cl x86/Release inlined try-catch leads to access
                    violation or std::length_error
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ki.stfu at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Hi! I use VS2019 16.7.2 with bundled LLVM/Clang 10.0.0, and I get AV or a
length_error & corrupted stack when compile the following code for x86/Release
using LLVM (clang-cl) toolset:

```

#include <new>

#define BOOST_ALL_NO_LIB
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp> // boost v1.73.0

//__declspec(noinline)
inline int to_code() noexcept
{
    try {
        throw;
    }
    catch (const std::bad_alloc&      ) { return 1; }
    catch (...                        ) { return 2; }
}

BOOST_AUTO_TEST_CASE(to_code_test) {
    try {
        throw std::bad_alloc();
    } catch (const std::bad_alloc&) {
        BOOST_TEST_CHECK(to_code() == 1);
    }
}
```

__declspec(noinline) helps to avoid this, and I also can't reproduce it w/o
try-catch block.

1. Create Console App (C++) in VS2019
2. Paste the code above
3. Configure boost 1.73.0
4. Change toolset to LLVM (clang-cl)
5. Build and run x86/Release

I zipped .sln file with source code, preprocessed rethrow_inlined_test.i, and
x86_Release_libboost_unit_test_framework.lib I used in my project in case you
need it.

-- 
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/20200914/9fdf6466/attachment-0001.html>


More information about the llvm-bugs mailing list