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

            Bug ID: 31489
           Summary: SEGV when swapping two std:function's at the same
                    location
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: zonrx...@gmail.com
                CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com
    Classification: Unclassified

This can be reproduced easily with the following program and commannds:

$ cat a.cpp
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

int main() {
  std::function<void()> a = []() {};
  std::swap(a, a);
  return 0;
}
$ clang++ -ggdb -std=c++11 -o a a.cpp
$ ./a
Segmentation fault: 11
$ lldb ./a
(lldb) target create "./a"
Current executable set to './a' (x86_64).
(lldb) r
...
   1780            __f_->__clone(__t);
   1781            __f_->destroy();
   1782            __f_ = 0;
-> 1783            __f.__f_->__clone((__base*)&__buf_);
   1784            __f.__f_->destroy();
   1785            __f.__f_ = 0;
   1786            __f_ = (__base*)&__buf_;

Both Mac (Apple LLVM version 8.0.0) and Linux (LLVM/Clang 3.8.0 release) have
the same problem at the same line.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to