[llvm-bugs] [Bug 27556] New: shared_ptr issues when allocator/deleter have throwing move constructor

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 28 10:01:28 PDT 2016


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

            Bug ID: 27556
           Summary: shared_ptr issues when allocator/deleter have throwing
                    move constructor
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: klemensbaum at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

There seems to be an issue in the shared_ptr implementation if the move
constructor of the deleter and/or allocator throw an exception. The standard
only guarantees that the copy constructor of the allocator and deleter may not
throw, nothing in there talks about move constructors.

In <memory>, line 4185, the allocator and deleter get passed into the _CntrlBlk
aka __shared_ptr_pointer by copy, which is fine and will not throw (note:
instead of always copying, we could use std::move_if_noexcept here).
The __shared_ptr_pointer constructor hands off the deleter and allocator into
the __compressed_pair by unconditional move (!). This can throw, and at line
4191, __d could already be moved-from or partially moved-from.

I think these calls to std::move should be replaced with std::move_if_noexcept.
There are more move constructors being invoked inside __compressed_pair, which
will also need to get looked at.

Line numbers refer to SVN revision 267901.

-- 
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/20160428/2486fdab/attachment.html>


More information about the llvm-bugs mailing list