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 6136831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:39:04+00:00 2026-05-23T17:39:04+00:00

while(!m_RemoveNodeList.empty()) { list<CNode *>::const_iterator const it = m_RemoveNodeList.begin(); CNode * const pNode = *it;

  • 0
while(!m_RemoveNodeList.empty())
{
    list<CNode *>::const_iterator const it = m_RemoveNodeList.begin();

    CNode * const pNode = *it;
    ASSERT(pNode != NULL);

    m_NodeList.remove( pNode );

    delete pNode; // crashing here

    m_RemoveNodeList.pop_front();
}

The above sometimes crashes at the delete with a read violation exception. could i be that i accidentally double delete?

both m_NodeList and m_RemoveNodeList are of type

 std::list<CNode *>

i should mention that CNode is a base class for several other classes. however none of those classes does anything in their destructors

  • 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-23T17:39:04+00:00Added an answer on May 23, 2026 at 5:39 pm

    There is no apparent crash in your code and looks fine.

    It could crash only if there are duplicate CNode* are stored inside the list<CNode*>; which will lead you to multiple delete. (it’s mentioned by @pau.estalella in the comments).

    You can try following method to catch if there are duplicate CNode*.

    map<CNode*, int> duplicate;
    while(m_RemoveNodeList.size() > 0)
    {
        list<CNode *>::const_iterator const it = m_RemoveNodeList.begin();
        CNode * const pNode = *it;
        if(duplicate.find(pNode) == duplicate.end())
          duplicate[pNode] = 1;
        else
          cout<<"Caught: "<<pNode<<endl;
    // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While I'm googling/reading for this answer I thought I would also ask here. I
While I'm busy here reading the FastCGI documentation (yeah, reading the 'friendly' manual), does
While I'm familiar with concurrent programming concepts such as mutexes and semaphores, I have
While I'm perfectly willing to believe that this has been asked elsewhere, I haven't
While I'm learning a new language, I'll typically put lots of silly println's to
I'm so surprise while I'm working in Fluent NHibernate. I got my legacy database
I’m new to Flex and Cairngorm.While I’m using ServiceLocator,I do run into the problem:
Often while I'm dealing with LINQ sequences, I want to send each item to
I'm copying data from one database to another and massaging the data while I'm
I'm currently using MongoDB to record application logs, and while I'm quite happy with

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.