[llvm-bugs] [Bug 30449] New: Segfault when move-assigning a std::map with an aligned Key

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 19 12:49:25 PDT 2016


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

            Bug ID: 30449
           Summary: Segfault when move-assigning a std::map with an
                    aligned Key
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: gael.guennebaud at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following example segfault with clang 3.8 and 3.9 when compiling with -O2
or -O3 (but runs fine with clang 3.7 and gcc):

#include <iostream>
#include <map>

struct alignas(16) Foo { int val; };

int main() {
  std::map<int, Foo> m;
  std::map<int, Foo> n{{1,{1}}};
  std::cout << "GOT HERE" << std::endl;
  m = std::move(n);  //  segfault happens here
  std::cout << "GOT HERE TOO" << std::endl;
}

Removing "alignas(16)" or "std::move" disables the issue.

Finally, here is the backtrace:

frame #0: 0x00000001000014f5 a.out`main [inlined]
std::__1::__tree<std::__1::__value_type<int, Foo>,
std::__1::__map_value_compare<int, std::__1::__value_type<int, Foo>,
std::__1::less<int>, true>, std::__1::allocator<std::__1::__value_type<int,
Foo> > >::__move_assign(this=<unavailable>) + 67 at __tree:1350 [opt]
    frame #1: 0x00000001000014b2 a.out`main [inlined]
std::__1::__tree<std::__1::__value_type<int, Foo>,
std::__1::__map_value_compare<int, std::__1::__value_type<int, Foo>,
std::__1::less<int>, true>, std::__1::allocator<std::__1::__value_type<int,
Foo> > >::operator=(this=<unavailable>) at __tree:1409 [opt]
    frame #2: 0x00000001000014b2 a.out`main [inlined] std::__1::map<int, Foo,
std::__1::less<int>, std::__1::allocator<std::__1::pair<int const, Foo> >
>::operator=(this=<unavailable>) at map:961 [opt]

-- 
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/20160919/0f17ea27/attachment.html>


More information about the llvm-bugs mailing list