[PATCH] D26123: Fix SegFault in Expected
Yichao Yu via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 29 17:06:22 PDT 2016
yuyichao created this revision.
yuyichao added a reviewer: lhames.
yuyichao added a subscriber: llvm-commits.
The placement new on getErrorStorage() is of the wrong type.
AFAICT this is the intent in https://reviews.llvm.org/rL265446 which somehow starts to trigger a segfault when the destructor of the unique_ptr is called after https://reviews.llvm.org/rL285426. Ref https://github.com/JuliaLang/julia/issues/19154
https://reviews.llvm.org/D26123
Files:
include/llvm/Support/Error.h
Index: include/llvm/Support/Error.h
===================================================================
--- include/llvm/Support/Error.h
+++ include/llvm/Support/Error.h
@@ -147,7 +147,7 @@
// Expected<T> needs to be able to steal the payload when constructed from an
// error.
- template <typename T> class Expected;
+ template <typename T> friend class Expected;
public:
/// Create a success value. Prefer using 'Error::success()' for readability
@@ -642,7 +642,7 @@
{
assert(Err && "Cannot create Expected<T> from Error success value.");
- new (getErrorStorage()) Error(std::move(Err));
+ new (getErrorStorage()) error_type(Err.takePayload());
}
/// Create an Expected<T> success value from the given OtherT value, which
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26123.76323.patch
Type: text/x-patch
Size: 764 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161030/3230bfa9/attachment.bin>
More information about the llvm-commits
mailing list