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

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 716468 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 1/4/2012 6:09:25 AM
Access Restriction Public


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

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.