Print Page | Close Window

[solved] ResetContent and heap corruption

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=23569
Printed Date: 26 April 2024 at 10:17pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [solved] ResetContent and heap corruption
Posted By: BobC
Subject: [solved] ResetContent and heap corruption
Date Posted: 13 February 2018 at 9:08pm
RE: Xtreme Toolkit Pro version 18.2.0 running on Windows 10 Pro, Visual Studio 2017, version 15.5.6

I use multiple report controls in an application for tracking stock market trades. One of those controls is an account list that allows the user to edit an account value. When the value is saved, the current report control is updated, and related UI components are sent a message about the update so they can do whatever they need to do, and in some cases, that means refreshing the contents of another report control that is currently out of view of the user.

I have found that after 3-4 account value updates, one of the other report controls crashes with a heap corruption error when calling ResetContent(). I have not been able yet to track down what's going wrong, so I thought I would put this out there and ask for help. It is not likely a threading issue because all of the action occurs in the UI thread.

Here is what the call stack looks like from the ResetContent call:





Replies:
Posted By: BobC
Date Posted: 22 March 2018 at 4:43pm
I had set this problem aside for awhile, but came back to it today, and figured out what was wrong.

I subclass CXTPReportRecord in places, and in two calls to CXTPReportControl::AddRecord(), I was using new() with the base class instead of my derived class.  That is, I was doing this:

CNoteRow* pRecord = static_cast<CNoteRow*>(m_repNotes.AddRecord(new CXTPReportRecord()));

but should have been doing this:

CNoteRow* pRecord = static_cast<CNoteRow*>(m_repNotes.AddRecord(new CNoteRow()));

I was doing it correctly in most other places, but I guess my brain stalled when writing the broken code.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net