Home Dashboard Directory Help
Search

Heap corruption when CObject-derived class throws from constructor when being called from make_shared by McNitt


Status: 

Closed
 as Fixed Help for as Fixed


1
0
Sign in
to vote
Type: Bug
ID: 716468
Opened: 1/4/2012 6:09:25 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

using std:make_shared to allocate an object that throws during the constructor causes a heap corruption.
Details
Sign in to post a comment.
Posted by Microsoft on 1/16/2012 at 5:40 PM
Hi,

Thanks for reporting this bug. We've already fixed it (back in August) and the fix will be available in VC11.

The problem, amusingly enough, was that make_shared<T>() invoked placement new with "new", which will consider class-specific operator new() implementations (or in this case, class-specific operator delete()). The fix was to use "::new", which is guaranteed to invoke "true placement new" at global scope (which is a no-op).

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by MS-Moderator07 [Feedback Moderator] on 1/4/2012 at 10:28 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by MS-Moderator01 on 1/4/2012 at 6:42 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Posted by McNitt on 1/4/2012 at 6:12 AM
We believe the problem is with placement new.
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
make_shared_CObject_heap_corruption.zip 1/4/2012 11 KB