New VC Runtime 14.0.24210.0 breaks MFC app built with VS 2015 Update 2 - by Jürgen Robel

Status : 

 


47
0
Sign in
to vote
ID 2892501 Comments
Status Closed Workarounds
Type Bug Repros 9
Opened 7/4/2016 8:48:19 AM
Access Restriction Public

Description

When you build an MFC app (using MFC in shared DLL) with Visual Studio 2015 Update 2, which creates a temporary CMFCToolBarButton object on the stack, 
and run it on a machine with VC Runtime 14.0.24210.0, which comes with VS 2015 Update 3, then the app is broken.

In a Debug build you get this error:
"Run-Time Check Failure #2 - Stack around the variable 'ToolbarButton' was corrupted"

In a Release build the reaction depends on what on the stack is overwritten. In my case the app doesn't start at all.

You may get an unhandled exception:
"Stack cookie instrumentation code detected a stack-based buffer overrun."

Example:
void CMainFrame::insertToolBarButton( UINT            nID,
                                      int             iImage,
                                      const CString & Text,
                                      bool            bSeparator,
                                      bool            bVisible )
  {
  BOOL bUserButton = FALSE;
  CMFCToolBarButton ToolbarButton( nID, iImage, Text, bUserButton );
  ToolbarButton.m_nStyle = TBBS_BUTTON;
  ToolbarButton.SetVisible( bVisible );
  ToolbarButton.m_bWrapText = FALSE;
  m_wndToolBar.InsertButton( ToolbarButton );
  }

When program execution reaches the closing curly brace you get the run-time check failure for the stack 
(or a heap corruption if you try to allocate the ToolbarButton on the heap).

The problem is caused by the new BOOL member m_bIsDragged in class CMFCToolBarButton.  
So memory layout differs between Update 2 and 3.  
When initializing m_bIsDragged in the constructor, the (stack) memory behind the ToolBarButton is overwritten.

The problem should arise also on all classes which are derived from CMFCToolBarButton:
CMFCColorMenuButton
CMFCCustomizeMenuButton
CMFCDropDownToolbarButton
CMFCOutlookBarPaneButton
CMFCRibbonGalleryMenuButton
CMFCToolBarComboBoxButton
CMFCToolBarDateTimeCtrl
CMFCToolBarEditBoxButton
CMFCToolBarFontComboBox
CMFCToolBarFontSizeComboBox
CMFCToolBarMenuButton
CMFCToolBarMenuButtonsButton
CMFCToolBarSpinEditBoxButton
CMFCToolBarSystemMenuButton
Sign in to post a comment.
Posted by Jürgen Robel on 8/3/2016 at 7:43 AM
After installing KB3165756 version 14.0.25424.00, released on 07/20/2016, I cannot load any symbols for updated MFC and VC runtime. It seems that Microsoft missed to upload the corresponding symbols to their symbol server, e.g.

    mfc140d.dll    C:\Windows\SysWOW64\mfc140d.dll    N/A    N/A    Cannot find or open the PDB file.        5    14.0.24212.0 built by: VCTOOLSD14ULDR    13.07.2016 21:18    0F610000-0FE43000    ...

    vcruntime140d.dll    C:\Windows\SysWOW64\vcruntime140d.dll    N/A    N/A    Cannot find or open the PDB file.        9    14.00.24212.0 built by: VCTOOLSD14ULDR    13.07.2016 21:07    59280000-5929C000    ...

There is a new Connect entry for this:

https://connect.microsoft.com/VisualStudio/Feedback/Details/2998787

@ThomasZ66:
MFC static libraries have been fixed by KB3165756 version 14.0.25425.01, released on 08/02/2016. Go to:

https://msdn.microsoft.com/en-us/library/mt752379.aspx
Posted by ThomasZ66 on 7/26/2016 at 7:17 AM
It might be related to https://connect.microsoft.com/VisualStudio/Feedback/Details/2977465, but we are using statically linked MFC and I have Patchlevel 14.0.25424.0 but a simple test does not work.
class CDFToolBarMenuButton : public CMFCToolBarMenuButton
{
public:
    CDFToolBarMenuButton()
    {
        m_bMenuMode = TRUE;
    }
};
Posted by CD_AlexanderW on 7/21/2016 at 10:22 PM
@James

I don't know if this already happened, but could you please update the standalone redist downloads, so that customers which only download the standalone versions do not use the version that breaks our already distributed software.

+ 1 for the Microsoft Update, since the old redists break a lot of already distributed programs.

thx!
Posted by James [MSFT] on 7/21/2016 at 7:20 AM
Hello,

Thank you again for reporting this issue. As noted in the comment below, this is fixed by the update to Visual Studio 2015 Update 3 that was made available on July 20, 2016. We would advise all of our developer customers to move forward to this update.

We do not currently plan to push out the updated redistributable via Microsoft Update.

Sincerely,

James McNellis
Visual C++ Libraries
james.mcnellis@microsoft.com
Posted by Jürgen Robel on 7/21/2016 at 2:21 AM
This issue has been fixed bei KB3165756 version 14.0.25424.00, released on 07/20/2016.

The member m_bIsDragged has been removed from CMFCToolBarButton. The fix contains the new VC Runtime 14.0.24212.0. When you install this on a client machine MFC apps built with VS 2015 Update 2 will run without issues.

Will Microsoft deploy the new VC runtime by Windows Update?
Posted by Microsoft on 7/7/2016 at 9:26 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If you require immediate assistance with this issue, please contact product support at http://support.microsoft.com/oas/default.aspx?prid=15825.
Posted by James McNellis on 7/7/2016 at 5:24 AM
Hello,

Thank you for reporting this. We are actively investigating this issue and will report back with an update shortly.

Sincerely,

James McNellis
Visual C++ Libraries
james.mcnellis@microsoft.com
Posted by Robert D Bruce on 7/6/2016 at 6:56 AM
This can be reproduced simply by creating an empty MFC application project template, compiling it with update 2 (redistributable 14.0.23918.0) , and then running it on a machine with the 14.0.24210.0 version of the Visual C++ 2015 redistributable.