Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6254497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:11:23+00:00 2026-05-24T14:11:23+00:00

When I compile in release mode, I have heap corruption on the deallocation of

  • 0

When I compile in release mode, I have heap corruption on the deallocation of a std::string.

In fact, in a DLL named Atc.dll, I call a function which is in another DLL named Utilies.dll. At the end of my function in Atc.dll, I have the heap corruption.

This my function in Atc.dll:

void CoreController::readConfigXMLFile()
{
    ConfigFileManager configFileManager;
    std::string pathXmlFilesTemp = configFileManager.getPathXMLFiles();
}

Then, this is the function getPathXMLFiles declared in Utilies.dll:

std::string ConfigFileManager::getPathXMLFiles()
{
    bool err = false;
    std::string ret = "";

    if (!mParserXml.getNodeTextValue(sPathXmlFilesTag, ret))
    {
        err = true;
    }

    if (err)
    {
        ret = sPathXMLFilesDefault;
    }

    return ret;
}

Note: If here I don’t call the function getNodeTextValue, the heap corruption doesn’t occur. So, there is the function getNodeTextValue which is in the same DLL than getPathXMLFiles:

bool ParseXml::getNodeTextValue(const string& path, string& nodeValue)
{
    DOMNode* child = XmlNode::getChildNodeByPath(xmlNode, path);
    //If path is valid.
    if(XmlNode::isValid(child))
    {
        char* str = XmlNode::getTextValue(child);
        //If node contains text.
        if(str != NULL)
        {
            nodeValue = str;
            XmlNode::freeXMLString(str);
            return true;
        }
    }
    //Either path is not valid or node does not contain text
    nodeValue = "";
    return false;
}

And this is where the heap corruption occurs (STL):

void _Tidy(bool _Built = false,
  size_type _Newsize = 0)
  { // initialize buffer, deallocating any storage
  if (!_Built)
   ;
  else if (this->_BUF_SIZE <= this->_Myres)
   { // copy any leftovers to small buffer and deallocate
   _Elem *_Ptr = this->_Bx._Ptr;
   if (0 < _Newsize)
    _Traits::copy(this->_Bx._Buf, _Ptr, _Newsize);
   this->_Alval.deallocate(_Ptr, this->_Myres + 1); // <-- HEAP CORRUPTION
   }
  this->_Myres = this->_BUF_SIZE - 1;
  _Eos(_Newsize);
  }

Can someone tell me why this heap corruption occurs and how to avoit it ?

Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:11:24+00:00Added an answer on May 24, 2026 at 2:11 pm

    The usual reason (on Windows) is that you allocate memory in 1 dll, pass it to another when then frees is. Often this is fine, but if each dll is built with a different CRT (C runtime library) then you get issues like this. The reason there is that the debug CRT does memory allocation slightly differently than the release CRT (mainly padding all allocs with guard blocks to show up buffer overruns etc).

    So make sure both dlls (and your app) all are built with the same CRT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to set compilation debug=false to get release mode dll's compiled on the
I have a Qt application that I compile in release configuration, run, and then
SUMMARY: How to compile in Release mode...I cannot get it to take what I
because of compatibility issues, I compile my project in VS2008 in release mode, but
When I compile my C# WPF project in release configuration mode with Visual Studio
I'm surprised to get a compile error in release mode with the following code.
When I compiled my application in release mode, I found that the Log4Net still
In a project I'm working on at the office, when we compile a release
My application is generating different floating point values when I compile it in release
when i want compile my app with the Distribution or Release method i get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.