Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - [solved] Heap corruption 17.1
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[solved] Heap corruption 17.1

 Post Reply Post Reply
Author
Message
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Topic: [solved] Heap corruption 17.1
    Posted: 22 February 2016 at 1:48pm
I integrated 17.1 into my projects and noticed a considerable amount of heap corruption going on.

I haven't had much opportunity to track exactly where the problems are happening but the new version is definitely unstable.

Noted indications of heap corruption in my application:

1. Last word of text is weirdly truncated in every MessageBox.
2. GIDPlus crashes in Flowgraph simply by opening a flowgraph.
3. Visual artifacts appear such as overdrawn lines, object placement.

These problems do not occur with v. 16.26. They only appear when I link with v. 17.1. The more complex the program, the more pronounced the issue. I typically use
"Yes (/LARGEADDRESSAWARE)" linker setting.

On their own, the individual components seem to have no error. All indications point to something in the new DPI processing system.. somewhere.

The nearest I could come to duplicating in a CJ sample was with CalendarDemo. This may or may not be related to the general condition, but the behavior is similar.

1. Build and run CalendarDemo using Static, Unicode settings. DLL seemed to produce the same results.

2. Select the test events.
3. Open options
4. Select Custom for tooltips from combobox
5. Move mouse cursor over an object with tool tips.

Heap will be corrupt in method: void CWnd::FilterToolTipMessage(MSG* pMsg)

        if ((tiHit.lpszText != LPSTR_TEXTCALLBACK) && (tiHit.hinst == 0))
            free(tiHit.lpszText);

There was nothing obvious through my brief code review to indicate why this is. It's abstracted enough to be difficult to tell. Someone with more familiarity with the code base might be able to find the problem more easily.

Build 17.1
Static Lib
Unicode
VS2010
Win 7 Pro Service Pack 1


Back to Top
markr View Drop Down
Senior Member
Senior Member


Joined: 01 August 2004
Status: Offline
Points: 442
Post Options Post Options   Thanks (0) Thanks(0)   Quote markr Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2016 at 12:54am
Out of curiosity, are you using any of the newer (Office 2013 or VS 2015) themes that make use of frame shadows?

- Mark R.
Back to Top
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2016 at 1:05pm
I didn't try a VS 2015 theme, but did test with Office 2013. The theme didn't seem to matter with regard to the problems. I used several of the different "Office" themes with no apparent difference.

I've noticed a number of topics posted here that point to memory issues. The effects seem random depending on how each application allocates memory... everything from crashes on exit to lockups during operation.
Back to Top
markr View Drop Down
Senior Member
Senior Member


Joined: 01 August 2004
Status: Offline
Points: 442
Post Options Post Options   Thanks (0) Thanks(0)   Quote markr Quote  Post ReplyReply Direct Link To This Post Posted: 01 March 2016 at 3:47pm
I get occasional crash reports, too, that appear to be caused by heap corruption of some type. I never saw these at all with XTP v16.x, but they now occur regularly with v17.

I'm not sure what to make of them - but I do know that in many cases the XTP hook manager (CXTPHookManager::HookWndProc) seems to be involved. 

Just wondering if you're seeing something similar.
Back to Top
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Posted: 28 May 2016 at 7:07pm
markr - I concur with your findings. I've concluded it must be something with the skin manager hook.

More details on the FlowGraph crash that I can reproduce 100% of the time.

No nodes, no connection points, no mark up, nothing. A blank FlowGraph page (with grid) should appear. Instead the program crashes with heap corruption.

Ctor works fine, activation works fine. Go to draw it and it's broken badly.

The problem seems to surface from this method:

LRESULT WINAPI CXTPSkinManagerApiHook::OnHookCallWindowProcW(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)

Example:

void CXTPFlowGraphControl::OnPaint()
{
....
>>> Crash here        delete pDC;
....

Which is calling this:

CXTPFlowGraphDrawContextGdiPlus::~CXTPFlowGraphDrawContextGdiPlus()
{
    SAFE_DELETE(m_pActivePen);
    SAFE_DELETE(m_pActiveFont);

    for (int i = 0; i < m_nBrushCount; i++)
    {
>>>> Crash here        delete m_arrBrushes.pBrush;
    }

    delete m_pGraphics;
}

The skin system appears problematic with v17+.

Win 7 pro
VS 2010
Static unicode debug build
CJ v 17.2.0

Back to Top
astoyan View Drop Down
Admin Group
Admin Group
Avatar

Joined: 24 August 2013
Status: Offline
Points: 284
Post Options Post Options   Thanks (0) Thanks(0)   Quote astoyan Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2016 at 11:34pm
The first reported issue with CalendarDemo has been fixed. It has nothing to do about ToolkitPro version, it's a bug in the sample:

Index: ToolkitPro/Samples/Calendar/CalendarDemo/CalendarDemoView.cpp
===================================================================
--- ToolkitPro/Samples/Calendar/CalendarDemo/CalendarDemoView.cpp       (revision 17881)
+++ ToolkitPro/Samples/Calendar/CalendarDemo/CalendarDemoView.cpp       (revision 17882)
@@ -1426,11 +1426,9 @@
                                        hitTest.pViewEvent->GetEvent()->GetSubject()
                                        );
 
-                               int nBuffSize = strToolText.GetLength()*2 +10;
-                               TCHAR* pBuffer = (TCHAR*)malloc(nBuffSize);
-                               
-                               STRCPY_S(pBuffer, nBuffSize, (LPCTSTR)strToolText);
-                               
+                               int nTextSize = strToolText.GetLength() + 1;
+                               TCHAR* pBuffer = (TCHAR*)::calloc(nTextSize, sizeof(TCHAR));
+                               STRCPY_S(pBuffer, nTextSize, (LPCTSTR)strToolText);
                                pTI->lpszText = pBuffer;


Regards,
  Alexander
Back to Top
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2016 at 12:48pm
Thanks for the fix astoyan. That corrected custom tooltips.
Back to Top
astoyan View Drop Down
Admin Group
Admin Group
Avatar

Joined: 24 August 2013
Status: Offline
Points: 284
Post Options Post Options   Thanks (0) Thanks(0)   Quote astoyan Quote  Post ReplyReply Direct Link To This Post Posted: 17 September 2016 at 9:45pm
Originally posted by Algae Algae wrote:


More details on the FlowGraph crash that I can reproduce 100% of the time.

No nodes, no connection points, no mark up, nothing. A blank FlowGraph page (with grid) should appear. Instead the program crashes with heap corruption.

Ctor works fine, activation works fine. Go to draw it and it's broken badly.

I have tried to reproduce it in our FlowGraphSample by modifying it so that it shows a blan page with grid and it worked just fine. Can you please make and submit a simple sample that crashes for you?

Regards,
  Alexander
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.